This is the mail archive of the newlib@sourceware.cygnus.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch: path search in execlp.c


Hello,

if you agree, I would commit the following patch to
libc/posix/execlp.c:

While searching in the path, a slash is appended to the path
in any  case before appending the file name of the executable.
This isn't correct if the path is '/' or -- generally -- if
the path ends in a slash. 

The below patch cares for that case. 

Regards,
Corinna

==== SNIP ====
--- execvp.c    2000/02/17 19:39:47     1.1.1.1
+++ execvp.c    2000/04/13 10:10:53
@@ -73,7 +73,7 @@ _DEFUN (execvp, (file, argv),
     {
       strccpy (buf, path, PATH_DELIM);
       /* An empty entry means the current directory.  */
-      if (*buf != 0)
+      if (*buf != 0 && buf[strlen(buf) - 1] != '/')
        strcat (buf, "/");
       strcat (buf, file);
       if (execv (buf, argv) == -1 && errno != ENOENT)
==== SNAP ====

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]