diff options
| author | John Polstra <jdp@FreeBSD.org> | 2000-12-04 01:45:57 +0000 |
|---|---|---|
| committer | John Polstra <jdp@FreeBSD.org> | 2000-12-04 01:45:57 +0000 |
| commit | 882cdc116d2cb17c92301e0a2aa8591274eb1db5 (patch) | |
| tree | adb7205c61bf01c48f3000aafda8a4c9d82b8088 /lib/libc | |
| parent | bd1c746647c5dc10612236fe325541ca1b3ba469 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/gen/setproctitle.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index 7d4fdae8ca6b..6b71d53e00df 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -126,6 +126,16 @@ setproctitle(const char *fmt, ...) oargc = ps_strings->ps_nargvstr; oargv = ps_strings->ps_argvstr; for (i = len = 0; i < oargc; i++) { + /* + * The program may have scribbled into its + * argv array, e.g., to remove some arguments. + * If that has happened, break out before + * trying to call strlen on a NULL pointer. + */ + if (oargv[i] == NULL) { + oargc = i; + break; + } snprintf(obuf + len, sizeof(obuf) - len, "%s%s", len ? " " : "", oargv[i]); if (len) |
