From owner-freebsd-audit Tue Dec 19 13:54:46 2000 From owner-freebsd-audit@FreeBSD.ORG Tue Dec 19 13:54:40 2000 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13]) by hub.freebsd.org (Postfix) with ESMTP id 843D037B400 for ; Tue, 19 Dec 2000 13:54:31 -0800 (PST) Received: from strontium.scientia.demon.co.uk ([192.168.91.36] ident=root) by scientia.demon.co.uk with esmtp (Exim 3.169 #1) id 148UiG-0004oZ-00; Tue, 19 Dec 2000 21:54:24 +0000 Received: (from ben@localhost) by strontium.scientia.demon.co.uk (8.11.1/8.11.1) id eBJLsEY28134; Tue, 19 Dec 2000 21:54:14 GMT (envelope-from ben) Date: Tue, 19 Dec 2000 21:54:14 +0000 From: Ben Smithurst To: Warner Losh Cc: audit@FreeBSD.ORG Subject: Re: printf(1) broken for some long format strings Message-ID: <20001219215413.H78749@strontium.scientia.demon.co.uk> References: <20001219143506.C78749@strontium.scientia.demon.co.uk> <200012191729.eBJHTps36903@billy-club.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200012191729.eBJHTps36903@billy-club.village.org> Sender: ben@scientia.demon.co.uk Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Warner Losh wrote: > if (len > copy_size) { > if (copy_size == 0) > newlen = 1024; what's the point of the special case for copy_size == 0? And that would break if more than 1k is needed the first time through, wouldn't it? (Or maybe I'm just not thinking straight at the moment.) Why not just use > newlen = ((len + 1023) >> 10) << 10; every time? > might be a little better. It will round the size to the next highest > k boundary, which will result in fewer malloc calls. A slightly > better way would be to find some way to round it up to the next power > of 2 so that you do even fewer malloc calls, but my bit tiddling foo > isn't awake yet this morning. that's probably over the top, since the maximum length before this change was 64 bytes, there can't be many places where more than that is needed or someone would have noticed this and fixed it before me. :-) -- Ben Smithurst / ben@FreeBSD.org / PGP: 0x99392F7D To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message