From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8435: misuse of error ("...%d...", ...) on 64-bit hosts Date: Sat, 09 Apr 2011 11:24:08 -0700 Organization: UCLA Computer Science Department Message-ID: <4DA0A448.7000203@cs.ucla.edu> References: <4D9CC60D.2090301@cs.ucla.edu> <4D9D68D8.6060200@cs.ucla.edu> <8339ltvrok.fsf@gnu.org> <4D9E21FB.70802@cs.ucla.edu> <83vcypt8zf.fsf@gnu.org> <4D9F9B74.6050908@cs.ucla.edu> <83d3kvubzp.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1302374258 18871 80.91.229.12 (9 Apr 2011 18:37:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 9 Apr 2011 18:37:38 +0000 (UTC) Cc: 8435@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 09 20:37:30 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q8d2H-00081e-8C for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Apr 2011 20:37:29 +0200 Original-Received: from localhost ([127.0.0.1]:51798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8d2G-0007ue-KI for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Apr 2011 14:37:28 -0400 Original-Received: from [140.186.70.92] (port=34861 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8d28-0007uA-U4 for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2011 14:37:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8d27-00034S-Uw for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2011 14:37:20 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8d27-00034O-SM for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2011 14:37:19 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q8cqE-00014J-IW; Sat, 09 Apr 2011 14:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Apr 2011 18:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8435 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8435-submit@debbugs.gnu.org id=B8435.13023734584048 (code B ref 8435); Sat, 09 Apr 2011 18:25:02 +0000 Original-Received: (at 8435) by debbugs.gnu.org; 9 Apr 2011 18:24:18 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q8cpW-00013D-7v for submit@debbugs.gnu.org; Sat, 09 Apr 2011 14:24:18 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q8cpT-00012z-LV for 8435@debbugs.gnu.org; Sat, 09 Apr 2011 14:24:16 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id C995A39E80B1; Sat, 9 Apr 2011 11:24:09 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JAm-b4V2Ufun; Sat, 9 Apr 2011 11:24:08 -0700 (PDT) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 8FD6E39E8082; Sat, 9 Apr 2011 11:24:08 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 In-Reply-To: <83d3kvubzp.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 09 Apr 2011 14:25:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45716 Archived-At: On 04/09/2011 12:20 AM, Eli Zaretskii wrote: >> Date: Fri, 08 Apr 2011 16:34:12 -0700 >> From: Paul Eggert > Then let's change doprnt to support an `int'... > Are there any problems with this approach? Yes: it'd be more work to do now, and will leave us with more code to maintain afterwards. > adding that support in other places has disadvantages that I > mentioned in my previous message. The disadvantages are small compared to the advantages. Most of the changes in the patch are needed regardless of whether doprnt is kept or discarded. The part about discarding doprnt shortens Emacs's code overall: it removes 283 lines (doprnt itself, plus scaffolding) and adds 17 lines (callers adjusting to the minor differences between doprnt and vsnprintf). This is a clear win. Part of the motivation here is that doprnt contains too many bugs. I've mentioned two or three, but here's another: while ('0' <= fmt[1] && fmt[1] <= '9') { if (n * 10 + fmt[1] - '0' < n) error ("Format width or precision too large"); n = n * 10 + fmt[1] - '0'; *string++ = *++fmt; } That overflow check is clearly wrong: it will miss many overflows. This doprnt bug, like the others, could be fixed by investing more time, but it's wasteful to spend time maintaining a buggy near-copy of vsnprintf. It's better software engineering practice to use vsnprintf instead.