On Wed, Oct 02, 2002 at 02:15:42PM +0300, Andrey Simonenko wrote: > Hello, > > Why is it needed to check both r->rulenum and (void *)r < lim in > sbin/ipfw2.c:list() ?
because the buffer has a limited size (nbytes) and you don't want to read past it. However there is a bug in the code below, because you should swap the checks (void *)r < lim && r->rulenum < 65535 Whether ipfw1.c has the same bug or not i don't remember, but that is irrelevant anyways. cheers luigi > /* > * Count static rules. They have variable size so we > * need to scan the list to count them. > */ > for (nstat = 1, r = data, lim = data + nbytes; > r->rulenum < 65535 && (void *)r < lim; > ++nstat, r = (void *)r + RULESIZE(r) ) > ; /* nothing */ > > Can I simply check r->rulenum < 65535 as it is done in sbin/ipfw.c:list() > ? > > TIA > > ps: please CC to my email. > > > To Unsubscribe: send mail to [EMAIL PROTECTED] > with "unsubscribe freebsd-net" in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-net" in the body of the message