diff options
author | jdp <jdp@FreeBSD.org> | 2000-12-04 01:26:29 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 2000-12-04 01:26:29 +0000 |
commit | 1a3b428b9eff10fd217e635573058a841bdab6b5 (patch) | |
tree | 859144eae86afa563a45956af9e2906fb5ecbb04 /lib | |
parent | 1fe497ac735107937d9e75edac22359ee806486a (diff) | |
download | FreeBSD-src-1a3b428b9eff10fd217e635573058a841bdab6b5.zip FreeBSD-src-1a3b428b9eff10fd217e635573058a841bdab6b5.tar.gz |
When recording the original arguments, don't (ab)use "nargc" for
iterating over the arguments. Doing so wipes out the value which
is about to be stored into the ps_strings structure.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/setproctitle.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index d0f224b..7d4fdae 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -65,6 +65,7 @@ setproctitle(const char *fmt, ...) static char *nargv[2] = { buf, NULL }; char **nargvp; int nargc; + int i; va_list ap; size_t len; unsigned long ul_ps_strings; @@ -124,12 +125,12 @@ setproctitle(const char *fmt, ...) /* Record our original args */ oargc = ps_strings->ps_nargvstr; oargv = ps_strings->ps_argvstr; - for (nargc = len = 0; nargc < oargc; nargc++) { + for (i = len = 0; i < oargc; i++) { snprintf(obuf + len, sizeof(obuf) - len, "%s%s", - len ? " " : "", oargv[nargc]); + len ? " " : "", oargv[i]); if (len) len++; - len += strlen(oargv[nargc]); + len += strlen(oargv[i]); if (len >= sizeof(obuf)) break; } |