From: kay.sievers@vrfy.org Date: Sun, 27 Mar 2005 22:18:49 +0000 (+0200) Subject: [PATCH] klibc: strlcpy/strlcat - don't alter destination if size == 0 X-Git-Tag: 057~23 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f8d44c220d811352b63c65b5a66403339005aac;p=systemd [PATCH] klibc: strlcpy/strlcat - don't alter destination if size == 0 --- diff --git a/klibc/klibc/strlcat.c b/klibc/klibc/strlcat.c index f397857e..fdd72ac3 100644 --- a/klibc/klibc/strlcat.c +++ b/klibc/klibc/strlcat.c @@ -26,7 +26,8 @@ size_t strlcat(char *dst, const char *src, size_t size) bytes++; } - *q = '\0'; + if (size) + *q = '\0'; return bytes; } diff --git a/klibc/klibc/strlcpy.c b/klibc/klibc/strlcpy.c index 8b36c43c..9e7b6bf9 100644 --- a/klibc/klibc/strlcpy.c +++ b/klibc/klibc/strlcpy.c @@ -19,7 +19,8 @@ size_t strlcpy(char *dst, const char *src, size_t size) bytes++; } - *q = '\0'; + if (size) + *q = '\0'; return bytes; } diff --git a/udev_libc_wrapper.c b/udev_libc_wrapper.c index 23cb7b43..d69f2ac4 100644 --- a/udev_libc_wrapper.c +++ b/udev_libc_wrapper.c @@ -58,7 +58,8 @@ size_t strlcpy(char *dst, const char *src, size_t size) bytes++; } - *q = '\0'; + if (size) + *q = '\0'; return bytes; } @@ -82,7 +83,8 @@ size_t strlcat(char *dst, const char *src, size_t size) bytes++; } - *q = '\0'; + if (size) + *q = '\0'; return bytes; } #endif /* __OWN_STRLCPYCAT__ */