]> arthur.barton.de Git - netatalk.git/commitdiff
fixed a nasty bug in strncasecmp (n > 0).
authoruhees <uhees>
Sat, 18 Aug 2001 07:45:46 +0000 (07:45 +0000)
committeruhees <uhees>
Sat, 18 Aug 2001 07:45:46 +0000 (07:45 +0000)
libatalk/util/strdicasecmp.c

index d143aaa1e7b630cefe2e0fd56d192c4712bf3507..d6b83bb4ffc228d1cee2a682c44eb92947db5307 100644 (file)
@@ -538,15 +538,16 @@ int strdiacasecmp( const char *s1, const char *s2 )
 
 int strndiacasecmp( const char *s1, const char *s2, size_t n )
 {
-    while ( --n >= 0 &&
+    while ( n > 0 &&
            _diacasemap[ (unsigned char) *s1 ] ==
            _diacasemap[ (unsigned char) *s2++ ] ) {
        if ( *s1++ == '\0' ) {
            return( 0 );
        }
+       n--;
     }
 
-    if (n < 0)
+    if (n == 0)
        return 0;
     return _diacasemap[ (unsigned char) *s1 ] -
           _diacasemap[ (unsigned char) *--s2 ];