diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-03-27 12:39:12 +0200 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:54:59 -0700 |
commit | 8a4c0c32f4252efb0f0adbf5cdc0261d359cd568 (patch) | |
tree | f2caa6a8e4ab8eb049172a23a6212346dab4b33e /klibc | |
parent | 6276fdd2ab9c0cbfd0fba3e0261a074e81932156 (diff) |
[PATCH] fix klibc's broken strlcpy/strlcat
udevinfo segfaults cause klibc's strlcpy writes behind the specified
size of the destination string. strlcat truncates the destination
string which is also not what you expect from a concatenation function.
Diffstat (limited to 'klibc')
-rw-r--r-- | klibc/klibc/strlcat.c | 4 | ||||
-rw-r--r-- | klibc/klibc/strlcpy.c | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/klibc/klibc/strlcat.c b/klibc/klibc/strlcat.c index 6111445f06..f397857e76 100644 --- a/klibc/klibc/strlcat.c +++ b/klibc/klibc/strlcat.c @@ -16,9 +16,11 @@ size_t strlcat(char *dst, const char *src, size_t size) q++; bytes++; } + if (bytes == size) + return (bytes + strlen(src)); while ( (ch = *p++) ) { - if ( bytes < size ) + if ( bytes+1 < size ) *q++ = ch; bytes++; diff --git a/klibc/klibc/strlcpy.c b/klibc/klibc/strlcpy.c index eb384c9885..8b36c43c00 100644 --- a/klibc/klibc/strlcpy.c +++ b/klibc/klibc/strlcpy.c @@ -13,7 +13,7 @@ size_t strlcpy(char *dst, const char *src, size_t size) char ch; while ( (ch = *p++) ) { - if ( bytes < size ) + if ( bytes+1 < size ) *q++ = ch; bytes++; |