Re: generic strncpy - off-by-one error

From: William Gallafent
Date: Tue Aug 12 2003 - 10:57:23 EST


On Tue, 12 Aug 2003 Valdis.Kletnieks@xxxxxx wrote:

> On Tue, 12 Aug 2003 23:50:06 +0900, Yoshinori Sato
> <ysato@xxxxxxxxxxxxxxxxxxxx> said:
> > - while (count) {
> > + while (count > 1) {
>
> Given that count is a size_t, which seems to be derived from 'unsigned int'
> or 'unsigned long' on every platform, how are these any different?

Er, consider the case of count == 1. Fenceposts can be dangerous things.

--
Bill Gallafent.
-
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/