From 781c77ed47d9977b7f40c7f8ed19f773819557c5 Mon Sep 17 00:00:00 2001 From: oes Date: Wed, 25 Sep 2002 13:00:41 +0000 Subject: [PATCH] Made strcmpic and strncmpic safe against NULL arguments (which are now treated as empty strings). --- src/miscutil.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/miscutil.c b/src/miscutil.c index cdf88350..0779c1aa 100644 --- a/src/miscutil.c +++ b/src/miscutil.c @@ -1,4 +1,4 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 2.1 2002/06/04 17:22:37 jongfoster Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 2.2 2002/08/26 11:16:33 sarantis Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/src/miscutil.c,v $ @@ -36,6 +36,9 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 2.1 2002/06/04 17:22:37 jongfoste * * Revisions : * $Log: miscutil.c,v $ + * Revision 2.2 2002/08/26 11:16:33 sarantis + * Fix typo. + * * Revision 2.1 2002/06/04 17:22:37 jongfoster * Adding comments * @@ -405,6 +408,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) ) ) @@ -435,7 +441,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) ) ) -- 2.39.2