From owner-freebsd-current@FreeBSD.ORG Sat Jul 28 22:44:34 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 429AF106566B for ; Sat, 28 Jul 2012 22:44:34 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) by mx1.freebsd.org (Postfix) with ESMTP id E27628FC16 for ; Sat, 28 Jul 2012 22:44:33 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id 15C6F25D3888; Sat, 28 Jul 2012 22:44:33 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id 39C68BE8553; Sat, 28 Jul 2012 22:44:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id fsL329NW6tQ7; Sat, 28 Jul 2012 22:44:30 +0000 (UTC) Received: from nv.sbone.de (nv.sbone.de [IPv6:fde9:577b:c1a9:31::2013:138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id B1C9ABE8552; Sat, 28 Jul 2012 22:44:30 +0000 (UTC) Date: Sat, 28 Jul 2012 22:44:29 +0000 (UTC) From: "Bjoern A. Zeeb" To: Arnaud Lacombe In-Reply-To: Message-ID: References: <20120725155211.GA33971@onelab2.iet.unipi.it> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Luigi Rizzo , current@freebsd.org Subject: Re: RFC: libkern version of inet_ntoa_r X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jul 2012 22:44:34 -0000 On Sat, 28 Jul 2012, Arnaud Lacombe wrote: > Hi, > > On Sat, Jul 28, 2012 at 6:14 PM, Bjoern A. Zeeb > wrote: >> On Wed, 25 Jul 2012, Luigi Rizzo wrote: >> >>> During some ipfw/dummynet cleanup i noticed that the libkern version of >>> inet_ntoa_r() is missing the buffer size argument that is present in >>> the libc counterpart. >>> >>> Any objection if i fix it ? >> >> >> And why exactly would you need it? What does libc do with it? Render >> partial IPv4 addresses? >> > Mitigate possibilities of memory corruption ? At the very least, allow > the following: > > { > char tmp[sizeof "255.255.255.255"]; char tmp[INET_ADDRSTRLEN]; > > KASSERT(size >= (sizeof tmp)); This would need to go into the called library function and cannot. > [...] So that gives you what extra checking exactly? That the programmer got the sizeof right rather than the buffer size? You pushed some more on the stack or reused an register for something that is supposed to be at a minial fixed length (nothing else lower allowed and will ever result in anything but misbehaviour) no matter what. It's not like it's inet_pton which can take totally different sizes. Which again leaves me with the question - why does libc have it? /bz -- Bjoern A. Zeeb You have to have visions! Stop bit received. Insert coin for new address family.