On Tue, Mar 30, 2010 at 07:32:14PM +0200, Yann Droneaud wrote: > Le mardi 30 mars 2010 à 19:12 +0200, Karel Zak a écrit : > > On Tue, Mar 30, 2010 at 05:17:55PM +0200, Yann Droneaud wrote: > > > You've made little mistakes in your fixes to mount and mkswap: > > > - one must check that endptr doesn't match the string pointer to convert > > > > if ((endptr && *endptr) || > > > > is enough, because endptr == str means that endptr is not empty > > > > See the output of this little test function call with an empty string: > > int test(const char *s) > { > char *endptr = NULL; > > unsigned long l; > > printf("s = '%s'\n", s); > > errno = 0; > l = strtoul(s, &endptr, 0); > > printf(" errno = %d\n", errno); > printf(" l = %lu 0x%08lX\n", l, l); > printf(" str = %p\n", s); > printf(" endptr = %p\n", endptr); > if (endptr != NULL) { > printf(" *endptr = '%c' (0x%02x)\n", *endptr, *endptr); > } > > return 0; > } > > s = '' > errno = 0 > l = 0 0x00000000 > str = 0x804865c > endptr = 0x804865c > *endptr = '' (0x00) Ah, empty string. OK. Thanks. I'll fix it. > endptr is not NULL and *endptr point to '\0'. > > > > otherwise empty string will be accepted as correct (eg *str == '\0', so > > > if endptr == str, *endptr == '\0'). > > > - when using strtoll(), overflow must be check against LLONG_MIN and LLONG_MAX. > > > > xnum < 0) > > > > is enough, because LLONG_MIN is smaller than zero. > > > > True, but you still have to correct the ULLONG_MAX use instead of > LLONG_MAX. We are talking about strtoll() (in mkswap). Karel -- Karel Zak <kzak@xxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html