From owner-freebsd-net Wed Oct 2 6:25:49 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED3CC37B401 for ; Wed, 2 Oct 2002 06:25:47 -0700 (PDT) Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DD4243E42 for ; Wed, 2 Oct 2002 06:25:47 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: from iguana.icir.org (localhost [127.0.0.1]) by iguana.icir.org (8.12.3/8.11.3) with ESMTP id g92DPkIb022434; Wed, 2 Oct 2002 06:25:46 -0700 (PDT) (envelope-from rizzo@iguana.icir.org) Received: (from rizzo@localhost) by iguana.icir.org (8.12.3/8.12.3/Submit) id g92DPkdE022433; Wed, 2 Oct 2002 06:25:46 -0700 (PDT) (envelope-from rizzo) Date: Wed, 2 Oct 2002 06:25:46 -0700 From: Luigi Rizzo To: Andrey Simonenko Cc: freebsd-net@FreeBSD.ORG Subject: Re: Q about sbin/ipfw2.c:list() Message-ID: <20021002062546.C22163@iguana.icir.org> References: <20021002141006.A1093-100000@lion.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20021002141006.A1093-100000@lion.com.ua>; from simon@simon.org.ua on Wed, Oct 02, 2002 at 02:15:42PM +0300 Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 majordomo@FreeBSD.org > with "unsubscribe freebsd-net" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message