diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-02-07 04:01:36 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-02-07 04:01:36 +0000 |
commit | 4dc434c804fdce0759cd89eb0de106f8634920c8 (patch) | |
tree | 9fc0692cc923e35f4196247bca2be2d5462dd050 /source3/lib | |
parent | 0326e054c30223083fcb4ba7e7f0e5885ecc895f (diff) | |
download | samba-4dc434c804fdce0759cd89eb0de106f8634920c8.tar.gz samba-4dc434c804fdce0759cd89eb0de106f8634920c8.tar.bz2 samba-4dc434c804fdce0759cd89eb0de106f8634920c8.zip |
make sure we don't run over the end of 'name' in unix_convert()
Thanks to Andrew Bartlett for spotting this.
(This used to be commit b4c210ccb05e71a8ddf1c25d028452dd5cd93c72)
Diffstat (limited to 'source3/lib')
-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 3c34df6f33..17c7cc29fe 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); |