]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
POSIX.1 says that argv[0] *should* be provided, but does not require it.
authorUlrich Drepper <drepper@redhat.com>
Fri, 27 Feb 1998 10:22:03 +0000 (10:22 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 27 Feb 1998 10:22:03 +0000 (10:22 +0000)
Handle missing argv[] values gracefully.

posix/execl.c
posix/execle.c

index 9aa13b958fb7ea4518d1ba9980f92b207a54375f..b6dbb1a0a1803febe7a25d9fa451be68978aa2db 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1994, 1998 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -37,11 +37,11 @@ DEFUN(execl, (path, arg), CONST char *path AND CONST char *arg DOTS)
   argv[0] = arg;
 
   va_start (args, arg);
-  i = 1;
-  do
+  i = 0;
+  while (argv[i++] != NULL)
     {
       argv[i] = va_arg (args, CONST char *);
-    } while (argv[i++] != NULL);
+    }
   va_end (args);
 
   return __execve (path, (char *CONST *) argv, __environ);
index a36d49a407e8263bd44797909e3fe594a8a897e9..fd343be3a47f58706994647d2844ac4706c0fbba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1998 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -32,11 +32,11 @@ DEFUN(execle, (path), CONST char *path AND CONST char *arg DOTS)
 
   va_start(args, arg);
   argv[0] = arg;
-  i = 1;
-  do
+  i = 0;
+  while (argv[i++] != NULL)
     {
       argv[i] = va_arg(args, CONST char *);
-    } while (argv[i++] != NULL);
+    }
 
   envp = va_arg(args, CONST char *CONST *);
   va_end(args);