Fixed a bug in strlcat() where it would not properly detect a no-change

condition if called with an initial string longer than the specified
size limit (due to an unsigned var's inability to go negative).
This commit is contained in:
Wayne Davison
2004-01-20 00:29:49 +00:00
parent beb9368481
commit 1fb8ec4b0d

View File

@@ -138,10 +138,9 @@
size_t len2 = strlen(s);
size_t ret = len1 + len2;
if (len1+len2 >= bufsize) {
len2 = bufsize - (len1+1);
}
if (len2 > 0) {
if (len1 < bufsize - 1) {
if (len2 >= bufsize - len1)
len2 = bufsize - len1 - 1;
memcpy(d+len1, s, len2);
d[len1+len2] = 0;
}