2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2016 Joyent, Inc.
17 * Regression test for 7076 where doing a putenv() call without an '=' sign
18 * may lead to a segmentation fault when doing a getenv() depending on the
19 * circumstances of the environment's layout. Verify putenv() mimics
27 #include <sys/debug.h>
32 if (putenv("FOO=bar") != 0) {
33 fprintf(stderr
, "failed to put FOO into the environment: %s\n",
38 if (getenv("FOO") == NULL
) {
39 fprintf(stderr
, "failed to retrieve FOO from the "
44 VERIFY0(unsetenv("FOO"));
46 if (getenv("FOO") != NULL
) {
47 fprintf(stderr
, "Somehow retrieved FOO from the "
48 "environment after unsetenv()!\n");
52 if (putenv("FOO=bar") != 0) {
53 fprintf(stderr
, "failed to put FOO into the environment: %s\n",
58 if (getenv("FOO") == NULL
) {
59 fprintf(stderr
, "failed to retrieve FOO from the "
64 VERIFY0(putenv("FOO"));
66 if (getenv("FOO") != NULL
) {
67 fprintf(stderr
, "Somehow retrieved FOO from the "
68 "environment after putenv()!\n");