From owner-freebsd-bugs@FreeBSD.ORG Fri Jun 12 09:47:23 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18DA4106567A; Fri, 12 Jun 2009 09:47:23 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 07F9D8FC21; Fri, 12 Jun 2009 09:47:23 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from freefall.freebsd.org (brian@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n5C9lMcc065654; Fri, 12 Jun 2009 09:47:22 GMT (envelope-from brian@freefall.freebsd.org) Received: (from brian@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n5C9lMlQ065650; Fri, 12 Jun 2009 09:47:22 GMT (envelope-from brian) Date: Fri, 12 Jun 2009 09:47:22 GMT Message-Id: <200906120947.n5C9lMlQ065650@freefall.freebsd.org> To: henning.petersen@t-online.de, brian@FreeBSD.org, freebsd-bugs@FreeBSD.org From: brian@FreeBSD.org Cc: Subject: Re: bin/135494: Use of sizeof in dhclinet.c. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2009 09:47:23 -0000 Synopsis: Use of sizeof in dhclinet.c. State-Changed-From-To: open->closed State-Changed-By: brian State-Changed-When: Fri Jun 12 09:43:16 UTC 2009 State-Changed-Why: The suggested patch is not correct. The options variable is an array of 256 tree_cache pointers and the code wants to set all pointers to NULL. The proposed change would just set the first pointer to NULL. To demonstrate: #include #include struct tree_cache { int x; int y; }; int main() { struct tree_cache *options[256]; int f; for (f = 0; f < 256; f++) options[f] = (struct tree_cache *)123; printf("Zeroing %u bytes\n", sizeof options); memset(options, 0, sizeof options); for (f = 0; f < 256; f++) if (options[f] != NULL) printf("Oops, %d is wrong\n", f); return 0; } http://www.freebsd.org/cgi/query-pr.cgi?pr=135494