diff options
Diffstat (limited to 'usr/src/test/libc-tests')
-rw-r--r-- | usr/src/test/libc-tests/runfiles/default.run | 2 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/Makefile | 1 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/env-OS-4089.c | 73 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/random/Makefile | 10 | ||||
-rw-r--r-- | usr/src/test/libc-tests/tests/random/chacha_tv.c | 4 |
5 files changed, 80 insertions, 10 deletions
diff --git a/usr/src/test/libc-tests/runfiles/default.run b/usr/src/test/libc-tests/runfiles/default.run index 9f6269ec71..d5783fcc72 100644 --- a/usr/src/test/libc-tests/runfiles/default.run +++ b/usr/src/test/libc-tests/runfiles/default.run @@ -106,6 +106,8 @@ timeout = 600 [/opt/libc-tests/tests/catopen] [/opt/libc-tests/tests/endian.32] [/opt/libc-tests/tests/endian.64] +[/opt/libc-tests/tests/env-OS-4089.32] +[/opt/libc-tests/tests/env-OS-4089.64] [/opt/libc-tests/tests/env-7076.32] [/opt/libc-tests/tests/env-7076.64] [/opt/libc-tests/tests/err/err.ksh] diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile index 16c002e0ef..e78af2e316 100644 --- a/usr/src/test/libc-tests/tests/Makefile +++ b/usr/src/test/libc-tests/tests/Makefile @@ -36,6 +36,7 @@ SUBDIRS = \ wctype PROGS = \ + env-OS-4089 \ aligned_alloc \ asprintf-14933 \ c11_threads \ diff --git a/usr/src/test/libc-tests/tests/env-OS-4089.c b/usr/src/test/libc-tests/tests/env-OS-4089.c new file mode 100644 index 0000000000..0f52201c79 --- /dev/null +++ b/usr/src/test/libc-tests/tests/env-OS-4089.c @@ -0,0 +1,73 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2016 Joyent, Inc. + */ + +/* + * Regression test for OS-4089 where doing a putenv() call without an '=' sign + * may lead to a segmentation fault when doing a getenv() depending on the + * circumstances of the environment's layout. Verify putenv() mimics + * unsetenv(). + */ + +#include <stdlib.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <sys/debug.h> + +int +main(void) +{ + if (putenv("FOO=bar") != 0) { + fprintf(stderr, "failed to put FOO into the environment: %s\n", + strerror(errno)); + return (1); + } + + if (getenv("FOO") == NULL) { + fprintf(stderr, "failed to retrieve FOO from the " + "environment!\n"); + return (1); + } + + VERIFY0(unsetenv("FOO")); + + if (getenv("FOO") != NULL) { + fprintf(stderr, "Somehow retrieved FOO from the " + "environment after unsetenv()!\n"); + return (1); + } + + if (putenv("FOO=bar") != 0) { + fprintf(stderr, "failed to put FOO into the environment: %s\n", + strerror(errno)); + return (1); + } + + if (getenv("FOO") == NULL) { + fprintf(stderr, "failed to retrieve FOO from the " + "environment!\n"); + return (1); + } + + VERIFY0(putenv("FOO")); + + if (getenv("FOO") != NULL) { + fprintf(stderr, "Somehow retrieved FOO from the " + "environment after putenv()!\n"); + return (1); + } + + return (0); +} diff --git a/usr/src/test/libc-tests/tests/random/Makefile b/usr/src/test/libc-tests/tests/random/Makefile index ed480dacb9..c1a1a18e1f 100644 --- a/usr/src/test/libc-tests/tests/random/Makefile +++ b/usr/src/test/libc-tests/tests/random/Makefile @@ -17,7 +17,6 @@ include $(SRC)/Makefile.master ROOTOPTPKG = $(ROOT)/opt/libc-tests TESTDIR = $(ROOTOPTPKG)/tests/random -ROOTBINDIR = $(ROOTOPTPKG)/bin PROGS = arc4random \ arc4random_prefork \ @@ -74,17 +73,12 @@ arc4random_preforksig: arc4random_forksig.c $(POST_PROCESS) chacha: chacha_tv.c - $(COMPILE.c) -DKEYSTREAM_ONLY -I$(SRC)/common/crypto/chacha -o chacha.o -c $(SRC)/common/crypto/chacha/chacha.c + $(COMPILE.c) -DKEYSTREAM_ONLY -I$(SRC)/common/crypto/chacha \ + -o chacha.o -c $(SRC)/common/crypto/chacha/chacha.c $(COMPILE.c) -I$(SRC)/common/crypto/chacha -o chacha_tv.o -c chacha_tv.c $(LINK.c) -o $@ chacha_tv.o chacha.o $(LDLIBS) $(POST_PROCESS) -$(ROOTBINDIR): - $(INS.dir) - -$(ROOTBINDIR)/%: % - $(INS.file) - $(TESTDIR): $(INS.dir) diff --git a/usr/src/test/libc-tests/tests/random/chacha_tv.c b/usr/src/test/libc-tests/tests/random/chacha_tv.c index 636ee114c8..a02c2905ab 100644 --- a/usr/src/test/libc-tests/tests/random/chacha_tv.c +++ b/usr/src/test/libc-tests/tests/random/chacha_tv.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright 2019 Joyent, Inc. */ /* @@ -285,7 +285,7 @@ chacha_test(uint8_t *key, uint8_t keylen, uint8_t *iv, uint8_t *bl0, bzero(res0, sizeof (res0)); bzero(res1, sizeof (res1)); chacha_keysetup(&ctx, key, keylen * 8, 0); - chacha_ivsetup(&ctx, iv); + chacha_ivsetup(&ctx, iv, NULL); chacha_encrypt_bytes(&ctx, res0, res0, sizeof (res0)); chacha_encrypt_bytes(&ctx, res1, res1, sizeof (res1)); ret = bcmp(res0, bl0, sizeof (res0)); |