mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
virStrncpy: fix to successfully copy empty string
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@virtuozzo.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
522b3d2b24
commit
cd9cbeffe9
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user