[Dnsmasq-discuss] pending works before 2.57 (was: config error after 2.56 upgrade)
carlos at fisica.ufpr.br
Wed Feb 16 16:44:12 GMT 2011
Matthias Andree (matthias.andree at gmx.de) wrote on 16 February 2011 15:45:
>I have some issues:
>#1 ...and before 2.57, please audit all tolower/toupper() and is*()
>ctype.h functions for proper casts.
>The code currently reads:
> char *r;
> if (*r != '*' && !isxdigit((int)*r))
>But should be ...!isxdigit((unsigned char)*r)) - mind the cast. Using
>(int) is extraneous and doesn't have any effect, but instead, it gives
>you the wrong sign extension and undefined behaviour on systems where
>the char type is not unsigned for *r between -128 and -2 inclusively.
>Quoting SUSv4: "The c argument is an int, the value of which the
>application shall ensure is a character representable as an unsigned
>char or equal to the value of the macro EOF. If the argument has any
>other value, the behavior is undefined." -- and that's what you get by
>casting to unsigned char (you can't get EOF here because it's not
>representable in a char without aliasing 0xFF -- that's useful however
>to apply the is*() functions to fgetc() results and thereabouts.)
This is actually a bug so it should be corrected now.
>#3 I'm also wondering if the stuff above shouldn't rather be
>!ishexnumber() for locale compatibility.
For the case of ethernet addresses there should be no problem.
More information about the Dnsmasq-discuss