From ee9a61841ac10d32d869a3893bc690c66f2bb1bb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 May 1998 22:11:24 +0000 Subject: includes.h: SunOS doesn't have strcasecmp, solaris versions prior to 2.6 don't have vsnprintf. locking_slow.c: slight tidy. make_smbcodepage.c: Use safe_strcpy instead of pstrcpy. nmbd_winsserver.c: Use pstrcpy instead of fstrcpy. smbmount.c: Fixed reported bug. util.c: Removed old fstrcpy/fstrcat functions. Jeremy. (This used to be commit f257d2e4bafd3944cca737699913a8d868279ca6) --- source3/lib/util.c | 71 ++++++------------------------------------------------ 1 file changed, 7 insertions(+), 64 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index f1ea1931c5..1e4a6fc27f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3370,10 +3370,11 @@ duplicate a string char *strdup(char *s) { char *ret = NULL; + int len; if (!s) return(NULL); - ret = (char *)malloc(strlen(s)+1); + ret = (char *)malloc((len = strlen(s))+1); if (!ret) return(NULL); - pstrcpy(ret,s); + safe_strcpy(ret,s,len); return(ret); } #endif @@ -4793,68 +4794,9 @@ int unistrcpy(char *dst, char *src) return num_wchars; } -#if 0 -/******************************************************************* -safe string copy into a fstring -********************************************************************/ -void fstrcpy(char *dest, char *src) -{ - int maxlength = sizeof(fstring) - 1; - int len; - if (!dest) { - DEBUG(0,("ERROR: NULL dest in fstrcpy\n")); - return; - } - - if (!src) { - *dest = 0; - return; - } - - len = strlen(src); - - if (len > maxlength) { - DEBUG(0,("ERROR: string overflow by %d in fstrcpy [%.50s]\n", - len-maxlength, src)); - len = maxlength; - } - - memcpy(dest, src, len); - dest[len] = 0; -} - -/******************************************************************* -safe string cat into a fstring -********************************************************************/ -void fstrcat(char *dest, char *src) -{ - int maxlength = sizeof(fstring) - 1; - int src_len, dest_len; - if (!dest) { - DEBUG(0,("ERROR: NULL dest in fstrcat\n")); - return; - } - - if (!src) { - return; - } - - src_len = strlen(src); - dest_len = strlen(dest); - - if (src_len + dest_len > maxlength) { - DEBUG(0,("ERROR: string overflow by %d in fstrcat [%.50s]\n", - src_len + dest_len - maxlength, src)); - src_len = maxlength - dest_len; - } - - memcpy(&dest[dest_len], src, src_len); - dest[dest_len + src_len] = 0; -} -#endif - /******************************************************************* -safe string copy into a known length string +safe string copy into a known length string. maxlength does not +include the terminating zero. ********************************************************************/ char *safe_strcpy(char *dest, char *src, int maxlength) { @@ -4884,7 +4826,8 @@ char *safe_strcpy(char *dest, char *src, int maxlength) } /******************************************************************* -safe string cat into a string +safe string cat into a string. maxlength does not +include the terminating zero. ********************************************************************/ char *safe_strcat(char *dest, char *src, int maxlength) { -- cgit