From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9515 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [libc-test][PATCH] add putenv double-free regression test Date: Sun, 6 Mar 2016 22:13:16 +0100 Message-ID: <20160306211315.GV29662@port70.net> References: <1457284958-12429-1-git-send-email-amonakov@ispras.ru> <1457293274-13000-1-git-send-email-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1457298813 32666 80.91.229.3 (6 Mar 2016 21:13:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2016 21:13:33 +0000 (UTC) Cc: Alexander Monakov To: musl@lists.openwall.com Original-X-From: musl-return-9528-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 06 22:13:31 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1acfzW-0004Ve-Ne for gllmg-musl@m.gmane.org; Sun, 06 Mar 2016 22:13:30 +0100 Original-Received: (qmail 13844 invoked by uid 550); 6 Mar 2016 21:13:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13820 invoked from network); 6 Mar 2016 21:13:28 -0000 Mail-Followup-To: musl@lists.openwall.com, Alexander Monakov Content-Disposition: inline In-Reply-To: <1457293274-13000-1-git-send-email-amonakov@ispras.ru> User-Agent: Mutt/1.5.24 (2015-08-30) Xref: news.gmane.org gmane.linux.lib.musl.general:9515 Archived-At: * Alexander Monakov [2016-03-06 22:41:14 +0300]: > --- > I see the musl patch has been committed, so here's the corresponding libc-test > regression test. > > It's pretty bare-bones since it just relies on libc's built-in double-free > detection. > > Also it's pretty lazy to use _GNU_SOURCE ftm to get putenv; I'm not sure > what's the expected style in libc-test for such things though. > src/functional/env.c also uses _GNU_SOURCE. > thanks, applied. used _XOPEN_SOURCE that is at least a standard. > src/regression/putenv-doublefree.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > create mode 100644 src/regression/putenv-doublefree.c > > diff --git a/src/regression/putenv-doublefree.c b/src/regression/putenv-doublefree.c > new file mode 100644 > index 0000000..f3a1f6c > --- /dev/null > +++ b/src/regression/putenv-doublefree.c > @@ -0,0 +1,16 @@ > +// commit 9543656cc32fda48fc463f332ee20e91eed2b768 2016-03-06 > +// __putenv could be confused into freeing storage that does not belong to the implementation > +#define _GNU_SOURCE > +#include > +#include > + > +int main(void) > +{ > + setenv("A", "1", 1); > + setenv("A", "2", 1); > + char *c = strdup("A=3"); > + putenv(c); > + setenv("A", "4", 1); > + free(c); > + return 0; > +} > -- > 2.1.3