patch: path search in execlp.c

Corinna Vinschen corinna@vinschen.de
Thu Apr 13 11:10:00 GMT 2000


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 ====


More information about the Newlib mailing list