mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Alexander Monakov <amonakov@ispras.ru>
Subject: Re: [libc-test][PATCH] add putenv double-free regression test
Date: Sun, 6 Mar 2016 22:13:16 +0100	[thread overview]
Message-ID: <20160306211315.GV29662@port70.net> (raw)
In-Reply-To: <1457293274-13000-1-git-send-email-amonakov@ispras.ru>

* Alexander Monakov <amonakov@ispras.ru> [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 <stdlib.h>
> +#include <string.h>
> +
> +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


      reply	other threads:[~2016-03-06 21:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-06 17:22 [PATCH] env: avoid leaving dangling pointers in __env_map Alexander Monakov
2016-03-06 19:41 ` [libc-test][PATCH] add putenv double-free regression test Alexander Monakov
2016-03-06 21:13   ` Szabolcs Nagy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160306211315.GV29662@port70.net \
    --to=nsz@port70.net \
    --cc=amonakov@ispras.ru \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).