chiark / gitweb /
[PATCH] klibc: strlcpy/strlcat - don't alter destination if size == 0
[elogind.git] / udev_libc_wrapper.c
index 23cb7b43168bc9ff7c3619bcf1440627f67f8b42..d69f2ac48e11dfb0dcc01daa6125089697307b93 100644 (file)
@@ -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__ */