NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/50934: pkill/pgrep segfaults in some cases



The following reply was made to PR bin/50934; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/50934: pkill/pgrep segfaults in some cases
Date: Tue, 21 Feb 2017 13:50:25 +0700

     Date:        Tue, 21 Feb 2017 02:35:01 +0000 (UTC)
     From:        Brian Marcotte <marcotte%panix.com@localhost>
     Message-ID:  <20170221023501.1B7987A291%mollari.NetBSD.org@localhost>
 
   |  Any update on this? I just encountered this again.
 
 Taking a look now.   The patch you supplied looks reasonable (though
 I will install it, assuming the build I am doing now to test it works,
 in a slightly different form).
 
 argv[0] can be NULL as processes are permitted to do anything they like
 to their arg vector.   If you want a guaranteed argv[0] == NULL test
 case, try building and running ...
 
 
 	main(int argc, char **argv)
 	{
 		argv[0] = 0;
 
 		pause();
 		exit(0);
 	}
 
 (kill it with a signal, like SIGINT, when you're done .. and to compile
 cleanly it probably needs <unistd.h> or something included to get the
 pause() and exit() prototypes - if you just cc it, without -W args (and
 it won't really be helped by optimisation...) it should be fine as is.
 
 All other uses of the arg vector in the code, except that one, look to
 be protected - though only against NULL, a program that does ...
 
 		argv[0] = 0xdeadbeef;
 
 might still cause problems (but if so, that will be a problem inside
 the kvm library).
 
 kre
 


Home | Main Index | Thread Index | Old Index