Re: Bug in strnicmp() noted in 2.1.119pre1 is still there!

Gordon Chaffee (chaffee@cs.berkeley.edu)
Mon, 31 Aug 1998 15:16:33 -0700 (PDT)


Michael O'Reilly <michael@metal.iinet.net.au> writes:
Horst von Brand <vonbrand@sleipnir.valparaiso.cl> writes:
> > [Bcc:d to linux-patches@samba.anu.edu.au]
> > It makes no sense to compare tolower(*s1) to tolower(*s2) all over the
> > place and then to just forget about that and compare the raw characters for
> > the result...
> >
> > --- linux/fs/isofs/inode.c.dist-2.1.120-2 Sun Aug 30 21:17:05 1998
> > +++ linux/fs/isofs/inode.c Sun Aug 30 21:20:32 1998
> > @@ -137,7 +137,7 @@
> > }
> > if (*s1 == 0 && *s2 == 0) return 0;
> > if (*s1 && *s2) {
> > - if (*s1 > *s2) return 1;
> > + if (tolower(*s1) > tolower(*s2)) return 1;
> > return -1;
> > }
> > if (*s1) return 1;

The code in question is slightly wrong, but it really doesn't matter.
If you look at the code usage in the file, it only cares if there is
any difference between the names. When the code gets to the line in
question above, it has already determined that a case insensitive
difference exists, and now it is trying to return the proper {1,0,-1}
value as defined by str*cmp. In this it fails, but none of its callers
care that it returned 1 instead of -1 or vice versa.

Yes, the code should be fixed, and the same problem exists in
fs/vfat/namei.c. Given that this is a bug in appearance only, there
really is no urgency to it.

> Well, if you're going to do that, you also need to change the equality
> line above to be:
> if (tolower(*s1) == tolower(*s2)) return 0;

No, there is no need. Look at the code again. A 0 return is properly
handled.

- Gordon

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html