Re: [PATCH] lib: vsprintf: fix invalid arg check

From: David Rientjes
Date: Thu Nov 11 2010 - 16:34:15 EST


On Fri, 12 Nov 2010, Vasiliy Kulikov wrote:

> OK, if the main reason here is return value type, then the correct
> handling should be:
>
> /* Reject out-of-range values early. Large positive sizes are
> used for unknown buffer sizes. */
> - if (WARN_ON_ONCE((int) size < 0))
> + if (WARN_ON_ONCE(size > INT_MAX)
> return 0;
>
> This should catch all underflows and too big integers.
>

That is equivalent since size_t is always unsigned; if you'd like to
change it, it should be presented only as a style change. More important
would be writing a less cryptic comment :)
--
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/