From: oes Date: Wed, 25 Sep 2002 12:58:51 +0000 (+0000) Subject: Made strcmpic and strncmpic safe against NULL arguments X-Git-Tag: v_3_0_1~136 X-Git-Url: http://www.privoxy.org/gitweb/@user-manual@@actions-help-prefix@CRUNCH-SERVER-HEADER?a=commitdiff_plain;h=5a34b5393dfd06a540c2b5c48803e4def352e85f;p=privoxy.git Made strcmpic and strncmpic safe against NULL arguments (which are now treated as empty strings). --- diff --git a/miscutil.c b/miscutil.c index 065cd5f6..b3628931 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,7 +1,7 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.36 2002/04/26 12:55:38 oes Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 1.37 2002/04/26 18:29:43 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $ + * File : $Source: /cvsroot/ijbswa//current/Attic/miscutil.c,v $ * * Purpose : zalloc, hash_string, safe_strerror, strcmpic, * strncmpic, chomp, and MinGW32 strdup @@ -36,6 +36,10 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.36 2002/04/26 12:55:38 oes Exp * * Revisions : * $Log: miscutil.c,v $ + * Revision 1.37 2002/04/26 18:29:43 jongfoster + * Fixing this Visual C++ warning: + * miscutil.c(710) : warning C4090: '=' : different 'const' qualifiers + * * Revision 1.36 2002/04/26 12:55:38 oes * New function string_toupper * @@ -395,6 +399,9 @@ char *safe_strerror(int err) *********************************************************************/ int strcmpic(const char *s1, const char *s2) { + if (!s1) s1 = ""; + if (!s2) s2 = ""; + while (*s1 && *s2) { if ( ( *s1 != *s2 ) && ( ijb_tolower(*s1) != ijb_tolower(*s2) ) ) @@ -425,7 +432,9 @@ int strcmpic(const char *s1, const char *s2) int strncmpic(const char *s1, const char *s2, size_t n) { if (n <= 0) return(0); - + if (!s1) s1 = ""; + if (!s2) s2 = ""; + while (*s1 && *s2) { if ( ( *s1 != *s2 ) && ( ijb_tolower(*s1) != ijb_tolower(*s2) ) )