diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-02-07 04:11:36 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-02-07 04:11:36 +0000 |
commit | 50edc1a8310c18ffc09cbd5dcc285122a638a4d7 (patch) | |
tree | bd6156455559f16f7f3fcf76588cd9e71a8e5ea3 /source3/lib/util_str.c | |
parent | 21ee739b830f35d71c70f3f2428fa189913af4c6 (diff) | |
download | samba-50edc1a8310c18ffc09cbd5dcc285122a638a4d7.tar.gz samba-50edc1a8310c18ffc09cbd5dcc285122a638a4d7.tar.bz2 samba-50edc1a8310c18ffc09cbd5dcc285122a638a4d7.zip |
merge from head
(This used to be commit fd3216dbcbaec7d64dd24fe2af6c4156935c47e9)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r-- | source3/lib/util_str.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 2a9ee0a868..60e0e3837f 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -479,11 +479,15 @@ char *safe_strcat(char *dest, const char *src, size_t maxlength) src_len = strlen(src); dest_len = strlen(dest); - + if (src_len + dest_len > maxlength) { DEBUG(0,("ERROR: string overflow by %d in safe_strcat [%.50s]\n", (int)(src_len + dest_len - maxlength), src)); - src_len = maxlength - dest_len; + if (maxlength > dest_len) { + memcpy(&dest[dest_len], src, maxlength - dest_len); + } + dest[maxlength] = 0; + return NULL; } memcpy(&dest[dest_len], src, src_len); |