From owner-freebsd-current Fri Nov 20 22:22:58 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA14761 for freebsd-current-outgoing; Fri, 20 Nov 1998 22:22:58 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA14756 for ; Fri, 20 Nov 1998 22:22:56 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id WAA06372; Fri, 20 Nov 1998 22:21:03 -0800 (PST) Received: from bubba.whistle.com( 207.76.205.7) by whistle.com via smap (V2.0) id xma006370; Fri, 20 Nov 98 22:20:43 -0800 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id WAA25723; Fri, 20 Nov 1998 22:20:43 -0800 (PST) From: Archie Cobbs Message-Id: <199811210620.WAA25723@bubba.whistle.com> Subject: Re: snprintf() in the kernel In-Reply-To: <199811210537.VAA20822@apollo.backplane.com> from Matthew Dillon at "Nov 20, 98 09:37:21 pm" To: dillon@apollo.backplane.com (Matthew Dillon) Date: Fri, 20 Nov 1998 22:20:43 -0800 (PST) Cc: grog@lemis.com, rnordier@nordier.com, freebsd-current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Matthew Dillon writes: > I've gone through your diffs. I found what I believe to be one genuine > bug, but read the notes and stuff below... you may have a problem with > some of the strncpy()'s you converted to snprintf's. Thanks very much! I didn't realize that the kernel strncpy() did a zero fill.. that makes the analysis more complicated. > dev/dpt/dpt_control.c > > This doesn't look right, you forgot to remove the strncpy and replace it > with the snprintf, but added the extra sizeof() argument as if you had. > > strncpy(compat_softc.ha_fw_version, > - dpt->board_data.firmware, 4); > + dpt->board_data.firmware, > + sizeof(compat_softc.ha_fw_version)); > compat_softc.ha_ccb = NULL; > compat_softc.ha_cblist = NULL; I actually left this one alone (sizeof(compat_softc.ha_fw_version) == 4) because it was impossible to determine whether this string is supposed to be nul-terminated or not .. the "ha_fw_version" field is not used anywhere in the kernel! So I don't know if it needs a nul or not. > netatm/spans/spans_util.c: > > I'm not sure about these ntohl() calls. Some of the defines just > macro the arguments through, others are routines, but historically > ntohl() has operated on a 32 bit quantity so we should probably > cast to ntohl() results to (long) in the s*printf() calls as well > as do the sprintf()->snprintf() conversion. Agreed.. it could matter on alpha hardware. > netinet/ip_divert.c: > > You might have to zero-fill unused space in sin_zero. I'm not sure. Hmm.. since Julian invented this hack I guess we can declare that "it doesn't have to be zero filled" :-) I'll work on adjusting for the concerns you pointed out.. Thanks, -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message