projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6ed67a1
)
prognam: Add diagnostic.
author
Bruno Haible
<bruno@clisp.org>
Sun, 6 Dec 2009 22:19:49 +0000
(23:19 +0100)
committer
Bruno Haible
<bruno@clisp.org>
Sun, 6 Dec 2009 22:19:49 +0000
(23:19 +0100)
ChangeLog
patch
|
blob
|
history
lib/progname.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index 90d6eb03c4c03485f32e282c4e56b0fa2680ea3b..be28f93c11c3545968344cf33472089188b1f21d 100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-1,3
+1,8
@@
+2009-12-06 Bruno Haible <bruno@clisp.org>
+
+ * lib/progname.c: Include stdio.h, stdlib.h.
+ (set_program_name): Reject a NULL argument.
+
2009-12-05 Eric Blake <ebb9@byu.net>
pipe2-safer: new module
2009-12-05 Eric Blake <ebb9@byu.net>
pipe2-safer: new module
diff --git
a/lib/progname.c
b/lib/progname.c
index c8660c94185dae61868f4cabb1a05ecdf97be1d1..2e82ac9ed6cc1b07b4eff0825452c8ae64213dcc 100644
(file)
--- a/
lib/progname.c
+++ b/
lib/progname.c
@@
-23,6
+23,8
@@
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <string.h>
@@
-44,6
+46,16
@@
set_program_name (const char *argv0)
const char *slash;
const char *base;
const char *slash;
const char *base;
+ /* Sanity check. POSIX requires the invoking process to pass a non-NULL
+ argv[0]. */
+ if (argv0 == NULL)
+ {
+ /* It's a bug in the invoking program. Help diagnosing it. */
+ fputs ("A NULL argv[0] was passed through an exec system call.\n",
+ stderr);
+ abort ();
+ }
+
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)