From owner-cvs-src@FreeBSD.ORG Fri May 6 06:54:21 2005 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A7BF216A4CE for ; Fri, 6 May 2005 06:54:21 +0000 (GMT) Received: from mail25.sea5.speakeasy.net (mail25.sea5.speakeasy.net [69.17.117.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 591E543D5E for ; Fri, 6 May 2005 06:54:21 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 11158 invoked from network); 6 May 2005 06:54:20 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail25.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 6 May 2005 06:54:20 -0000 Received: from hydrogen.funkthat.com (uzyroz@localhost.funkthat.com [127.0.0.1])j466sKmo041337; Thu, 5 May 2005 23:54:20 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id j466sKxx041336; Thu, 5 May 2005 23:54:20 -0700 (PDT) Date: Thu, 5 May 2005 23:54:19 -0700 From: John-Mark Gurney To: "M. Warner Losh" Message-ID: <20050506065419.GE2670@funkthat.com> References: <20050506032202.GC2670@funkthat.com> <20050505.232214.96921001.imp@bsdimp.com> <20050506062013.GD2670@funkthat.com> <20050506.002419.88383520.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050506.002419.88383520.imp@bsdimp.com> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: cvs-src@freebsd.org cc: src-committers@freebsd.org cc: cvs-all@freebsd.org cc: cperciva@freebsd.org Subject: Re: cvs commit: src/sys/kern subr_bus.c subr_rman.c vfs_subr.c src/sys/net if_mib.c src/sys/netinet ip_divert.c raw_ip.c udp_usrreq.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2005 06:54:21 -0000 Warner Losh wrote this message on Fri, May 06, 2005 at 00:24 -0600: > Yes, I understand that. But Like I said before, it is better to zero > the entire hunk of memory with bzero or M_ZERO.... > > The problem with strncpy is that it doesn't guarantee NUL > termination when strlen(s) > sizeof(d). And depending upon the interface, this is a good thing... I know that there are a few interfaces out there that use all chars for the array and assume that the userland program knows that when the array is full, to self terminate... Luckily, with such things as printf, you can still safely print such a string... (Hint to the other readers: It involves a `.' and a `*'.) But now we are getting down into semantics... I was just pointing out that if the buffer was filled with strncpy, we don't have to worry about leaking information... I didn't completely understand this till just over a year ago, and I'm probably not the only one that forgets/doesn't remeber/never knew that strncpy behaved this way... I didn't see any cases of this in the patches that were submitted, but I also only checked one file... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."