From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#8401: removing duplication and improving the readlink code Date: Fri, 01 Apr 2011 11:33:37 +0300 Message-ID: <83vcyypdzy.fsf@gnu.org> References: <4D9574F2.20108@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1301647049 20054 80.91.229.12 (1 Apr 2011 08:37:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 1 Apr 2011 08:37:29 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 01 10:37:25 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 1Q5ZrA-00046d-Ib for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 10:37:25 +0200 Original-Received: from localhost ([127.0.0.1]:36414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5Zr8-0001B9-CK for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 04:37:22 -0400 Original-Received: from [140.186.70.92] (port=60974 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5Zr2-0001B2-UR for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:37:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5Zqy-00046Y-GN for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:37:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5Zqy-00046T-BT for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:37:12 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q5Zos-0001iR-42; Fri, 01 Apr 2011 04:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Apr 2011 08:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8401 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.13016468966585 (code B ref -1); Fri, 01 Apr 2011 08:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Apr 2011 08:34:56 +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 1Q5Zol-0001iA-PS for submit@debbugs.gnu.org; Fri, 01 Apr 2011 04:34:56 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5Zok-0001hw-2Q for submit@debbugs.gnu.org; Fri, 01 Apr 2011 04:34:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5Zod-0003kg-VZ for submit@debbugs.gnu.org; Fri, 01 Apr 2011 04:34:48 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:43233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5Zod-0003ka-No for submit@debbugs.gnu.org; Fri, 01 Apr 2011 04:34:47 -0400 Original-Received: from [140.186.70.92] (port=42034 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5Zoc-0008BC-Kl for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:34:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5Zob-0003kB-30 for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:34:46 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:54539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5Zoa-0003k1-QT for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 04:34:45 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LIY00800T3KES00@a-mtaout20.012.net.il> for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 11:33:36 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.126.47.180]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LIY007JJT3YPL90@a-mtaout20.012.net.il>; Fri, 01 Apr 2011 11:33:35 +0300 (IDT) In-reply-to: <4D9574F2.20108@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 01 Apr 2011 04:35: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:45556 Archived-At: > Date: Thu, 31 Mar 2011 23:47:14 -0700 > From: Paul Eggert > CC: Eli Zaretskii > > In two places Emacs calls readlink with similar code to reallocate > buffers until there's enough room to store the symbolic link's value. > And in both places there are minor problems with overflow, since Emacs > uses 32-bit int where modern 64-bit systems use 64-bit ssize_t, and it > doesn't check for overflow in buffer size calculations. These > problems cause GCC to complain, if warnings are enabled. I plan to > fix the problems with the following patch, which substitutes a gnulib > implementation of the same basic readlink idea; this implementation > does more-careful buffer size checking, and makes it possible to > avoid the malloc+free in the usual case. Isn't much easier and much more elegant to use ssize_t instead of an int for the buffer sizes in both cases? > This patch adds a couple of dependencies so it may affect the > Windows build. If this patch is accepted, the new emacs_readlink function will be a trivial "fail" stub on Windows. I don't see a need to compile in all this gnulib code just to return NULL because readlink always fails.