When GCC tries to resolve paths to executables it generates an exec prefix
based on argv[0]. It does that using the make_relative_prefix_1 function in
libiberty (make-relative-prefix.c). If argv[0] doesn't contain a path (i.e. it
only reads "gcc"), make_relative_prefix_1 searches the PATH to find the full
path to the current executable.

When checking candidates however, it only checks the executable bit to
determine whether or not it found the current executable. This means that when
there is a directory with the same name as the executable in the PATH, this
mechanism will produce a wrong prefix.

Attached is a patch that uses stat to determine whether the candidate file is a
regular file at all, hence skipping directories.


-- 
           Summary: libiberty make_relative_prefix_1 mistakes directories
                    for executables
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mmlr at mlotz dot ch
  GCC host triplet: i586-pc-haiku
GCC target triplet: i586-pc-haiku


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38966

Reply via email to