Re: [PATCH] Fix %x parsing in vsscanf()

From: viro
Date: Tue Sep 23 2003 - 19:56:06 EST


On Tue, Sep 23, 2003 at 06:02:58PM -0700, Deepak Saxena wrote:
> On Sep 23 2003, at 23:26, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx was caught saying:
> > The following, AFAICS, would be correct:
> >
> > if (*cp == '0') {
> > cp++;
> > if (unlikely((*cp == 'x' || *cp == 'X') && isxdigit(cp[1]))) {
> > if (!base || base == 16) {
> > cp++;
> > base = 16;
> > }
> > } else if (!base)
> > base = 8;
> > } else if (!base)
> > base = 10;
>
> We can remove everything but "base = 10;" from the second "else if"
> clause b/c by this point we're guaranteed that it's not a hex or
> octal value.

Bzzert. strtoul() with e.g. base 8 on "1234" should parse it as octal.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/