[PATCH 1/1] virStrncpy: fix to successfully copy empty string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After [1] we got failure on attempt to copy empty string.
Before the patch empty string was copied successfuly.
Restore the original behaviour.

[1] 7d70a63b util: Improve virStrncpy() implementation

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/util/virstring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virstring.c b/src/util/virstring.c
index 2064944b0b..a4cc7e9c0a 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -786,7 +786,7 @@ virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
     if (n == -1)
         n = src_len;
 
-    if (n <= 0 || n > src_len || n > (destbytes - 1))
+    if (n > src_len || n > (destbytes - 1))
         return -1;
 
     memcpy(dest, src, n);
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux