]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix an inappropriate free of a non-dynamic value. While here, make the
authormarcel <marcel@FreeBSD.org>
Wed, 18 Dec 2013 17:03:43 +0000 (17:03 +0000)
committermarcel <marcel@FreeBSD.org>
Wed, 18 Dec 2013 17:03:43 +0000 (17:03 +0000)
commit566238caa7ea8d8f087bfebc41b84642cb0afecc
tree02f96a096f18cd791852dfdd15d7fe8ec6bc6b37
parentdb2aa85f74a51d6063fdfcae9ee7c78a198a5725
Fix an inappropriate free of a non-dynamic value. While here, make the
code more naive and robust:
1.  When setting ev_value, also always set ev_flags appropriately
2.  Always check ev_value and ev_flags before calling free.

Both the value and the EV_DYNAMIC property can come directly from the
consumers of the environment functionality, so it's good to be careful.
And since this code is typically not looked at for long periods of
time, it's good to have it be a little "dumb-looking".

Trigger case for the bug:
        env_setenv("foo", 0, "1", NULL, NULL);
        env_setenv("foo", 0, "2", NULL, NULL);

Obtained from: Juniper Networks, Inc.
lib/libstand/environment.c