Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gnu.utils.bug Subject: [PATCH] Avoid usage of PATH_MAX. Date: Sat, 07 Mar 2020 15:54:11 +0100 Lines: 61 Approved: bug-gnu-utils@gnu.org Message-ID: References: <8736ak8bcc.fsf@gnu.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: usenet.stanford.edu 1583593493 21159 209.51.188.17 (7 Mar 2020 15:04:53 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-gnu-utils@gnu.org Envelope-to: bug-gnu-utils@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Mailman-Approved-At: Sat, 07 Mar 2020 10:04:51 -0500 X-BeenThere: bug-gnu-utils@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU utilities List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <8736ak8bcc.fsf@gnu.org> Xref: csiph.com gnu.utils.bug:2278 --=-=-= Content-Type: text/plain Hi! Initially I sent this patch to bug-less@gnu.org, through fencepost, and got a bounce. Also, I went to look for the archives, but it seems that bug-less is not a list? Greetings, janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Avoid-usage-of-PATH_MAX.patch >From ef652341ed8b2c14ac40312ccd4ed329cb69fd0c Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 7 Mar 2020 14:57:19 +0100 Subject: [PATCH] Avoid usage of PATH_MAX. * filename.c (lrealpath): Have realpath allocate the buffer. Fixes compilation on the Hurd and avoids possible buffer overflow on other systems. --- filename.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filename.c b/filename.c index e420837..faa71b0 100644 --- a/filename.c +++ b/filename.c @@ -795,9 +795,9 @@ lrealpath(path) char *path; { #if HAVE_REALPATH - char rpath[PATH_MAX]; - if (realpath(path, rpath) != NULL) - return (save(rpath)); + char *rpath = NULL; + if ((rpath = realpath(path, rpath)) != NULL) + return (rpath); #endif return (save(path)); } -- 2.24.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com --=-=-=--