Bug 21706 - MAXPATHLEN usage in [gcc]/gcc/tlink.c
Summary: MAXPATHLEN usage in [gcc]/gcc/tlink.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks: 21824
  Show dependency treegraph
 
Reported: 2005-05-22 12:12 UTC by Alfred M. Szmidt
Modified: 2008-11-20 13:26 UTC (History)
4 users (show)

See Also:
Host: i686-pc-gnu0.3
Target: i686-pc-gnu0.3
Build: i686-pc-gnu0.3
Known to work:
Known to fail:
Last reconfirmed: 2006-02-13 03:56:40


Attachments
Poposed patch for gcc/tlink.c (638 bytes, patch)
2005-08-08 21:04 UTC, Thomas Schwinge
Details | Diff
better patch (478 bytes, patch)
2008-11-09 23:52 UTC, Samuel Thibault
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alfred M. Szmidt 2005-05-22 12:12:58 UTC
Please do not use MAXPATHLEN, it is a arbitrary limit, and is not
defined on GNU.  Currently gcc 4.0.0 is unbuildable on GNU since
[gcc]/gcc/tlink.c assumes that MAXPATHLEN is defined.  Please do not
use these kind of limits in GNU programs.

Suggested fix is to declare initial_cwd as:

  char *initial_cwd;

and then instead of doing:

  getcwd (initial_cwd, sizeof (initial_cwd));

do:

  initial_cwd = getcwd (NULL, 0);

Note: getcwd (NULL, 0) is a GNU extention, and might not be available
on non-GNU platforms.  (End of Note)

Sorry for not supplying a patch, happy hacking.
Comment 1 Andrew Pinski 2005-05-22 14:04:01 UTC
What about using PATH_MAX which is part of the POSIX standard?

Comment 2 Gabriel Dos Reis 2005-05-22 15:35:15 UTC
Subject: Re:  MAXPATHLEN usage in [gcc]/gcc/tlink.c

"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| What about using PATH_MAX which is part of the POSIX standard?

I think the point was about arbitray limit; and as far as I can tell
GNU does not claim to be POSIX, does it? ;-)

-- Gaby
Comment 3 Andreas Schwab 2005-05-22 15:36:51 UTC
Like most POSIX limits PATH_MAX may not be defined if the actual limit is not  
fixed.  
Comment 4 Alfred M. Szmidt 2005-05-26 12:59:23 UTC
(In reply to comment #3)
> Like most POSIX limits PATH_MAX may not be defined if the actual limit is not  
> fixed.  

Correct, and GNU doesn't have such a limit for the length of filenames, the
number of arguments passed to a program or the length of a hostname.  And
probobly a whole bunch of other things that have slipped my mind right now.
All of this is perfectly compliant with POSIX.
Comment 5 Andrew Pinski 2005-06-19 14:00:56 UTC
Confirmed.
Comment 6 Thomas Schwinge 2005-08-08 21:04:29 UTC
Created attachment 9447 [details]
Poposed patch for gcc/tlink.c

Index: gcc/ChangeLog
2005-08-05  Alfred M. Szmidt  <ams@gnu.org>

	* tlink.c (tlink_init): Use dynamic allocation for INITIAL_CWD.
Comment 7 Samuel Thibault 2008-11-09 23:50:20 UTC
libiberty actually already has its own powerful getpwd () Attaching patches currently fails, I'll try to submit later if I remember (else remind me). 
Comment 8 Samuel Thibault 2008-11-09 23:52:49 UTC
Created attachment 16643 [details]
better patch
Comment 9 Thomas Schwinge 2008-11-20 13:26:35 UTC
Fixed on trunk as rev142043.