Date: Mon, 4 Dec 2000 04:35:03 +0200 (EET) From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/lib/libc/gen setproctitle.c Message-ID: <200012040235.eB42Z3A16145@hades.hell.gr> In-Reply-To: <200012040145.eB41jw809701@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
John Polstra <jdp@FreeBSD.ORG> wrote:
>
> Modified files:
> lib/libc/gen setproctitle.c
> Log:
> When recording the original arguments, stop short if we encounter
> a NULL argument. Some programs change the contents of the argv
> array, typically to remove some special arguments. They shorten
> argv by storing a NULL where an argument pointer used to be. Such
> programs core dumped if they called setproctitle(), because it
> would try to apply strlen() to a NULL pointer.
What about avoiding parts of oargv[] in setproctitle() that are set to
NULL by those programs? I haven't tested the following small patch to
setproctitle.c, but I will test it tomorrow when I get to my development
box at work. I am sending it anyway, since someone might have the time to
check this by 09:00 EEST this morning.
- giorgos
Index: setproctitle.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/setproctitle.c,v
retrieving revision 1.12
diff -u -r1.12 setproctitle.c
--- setproctitle.c 2000/08/01 06:37:09 1.12
+++ setproctitle.c 2000/12/04 02:31:33
@@ -129,6 +129,8 @@
len ? " " : "", oargv[nargc]);
if (len)
len++;
+ if (oargv[nargc] == NULL) /* avoid NULL pointers in oargv[] */
+ continue;
len += strlen(oargv[nargc]);
if (len >= sizeof(obuf))
break;
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200012040235.eB42Z3A16145>
