From 98bf10bc5df6eb1c3b71d51cc60ef4bf25f57d97 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sun, 2 Feb 1997 18:12:36 +0000 Subject: util.c: StrCaseCmp and StrnCaseCmp terminated incorrectly, giving false answers when a string was partially identical. this issue is still outstanding, and needs to be investigated further. loadparm.c: added lp_logon_path() parameter. ipc.c: in NetUserGetInfo, lp_logon_path() can be returned instead of always specifying \\SAMBA_SERVER\HOMES (which may not necessarily exist). it is now possible to specify lp_logon_path() as \\ARBITRARY_SERVER\%U, just like NT server can. the default is \\SAMBA_SERVER\HOMES, just like it used to be. lkcl (This used to be commit d5b6ad7cb87d6b1a9342f027ac4f57ffdb54b4f3) --- source3/lib/util.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 318ac3fc61..dbf8a377bb 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -796,25 +796,32 @@ char *attrib_string(int mode) /******************************************************************* case insensitive string compararison ********************************************************************/ -int StrCaseCmp(char *s, char *t) +int StrCaseCmp(char const *s, char const *t) { - for (; tolower(*s) == tolower(*t); ++s, ++t) - if (!*s) return 0; + /* compare until we run out of string, either t or s, or find a difference */ + while (*s && *t && tolower(*s) == tolower(*t)) + { + s++; t++; + } - return tolower(*s) - tolower(*t); + return(tolower(*s) - tolower(*t)); } /******************************************************************* case insensitive string compararison, length limited ********************************************************************/ -int StrnCaseCmp(char *s, char *t, int n) +int StrnCaseCmp(char const *s, char const *t, int n) { - while (n-- && *s && *t) { - if (tolower(*s) != tolower(*t)) return(tolower(*s) - tolower(*t)); + /* compare until we run out of string, either t or s, or chars */ + while (n-- && *s && *t && tolower(*s) == tolower(*t)) + { s++; t++; } + + /* not run out of chars - strings are different lengths */ if (n) return(tolower(*s) - tolower(*t)); + /* identical up to where we run out of chars, and strings are same length */ return(0); } -- cgit