diff options
| author | beck <> | 2017-05-02 04:03:06 +0000 |
|---|---|---|
| committer | beck <> | 2017-05-02 04:03:06 +0000 |
| commit | 710782e8c80f6152718ade9fe0773c70022dc530 (patch) | |
| tree | 658860809b68caae19af6b218f34c1f21495c385 /src | |
| parent | 2b561cb0e87f2ee535e8c64907883cd275ad3fec (diff) | |
| download | openbsd-710782e8c80f6152718ade9fe0773c70022dc530.tar.gz openbsd-710782e8c80f6152718ade9fe0773c70022dc530.tar.bz2 openbsd-710782e8c80f6152718ade9fe0773c70022dc530.zip | |
Add regress for free functions that should be safe with NULL
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/free/Makefile | 20 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/free/freenull.c | 43 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/free/Makefile b/src/regress/lib/libcrypto/free/Makefile new file mode 100644 index 0000000000..cde5cb6702 --- /dev/null +++ b/src/regress/lib/libcrypto/free/Makefile | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2017/05/02 04:03:06 beck Exp $ | ||
| 2 | |||
| 3 | TESTS = \ | ||
| 4 | freenull | ||
| 5 | |||
| 6 | REGRESS_TARGETS= all_tests | ||
| 7 | |||
| 8 | LDADD= -lcrypto | ||
| 9 | DPADD= ${LIBCRYPTO} ${LIBSSL} | ||
| 10 | LDFLAGS+= -lcrypto | ||
| 11 | CFLAGS+= -DLIBRESSL_INTERNAL | ||
| 12 | |||
| 13 | CLEANFILES+= ${TESTS} | ||
| 14 | |||
| 15 | all_tests: ${TESTS} | ||
| 16 | @for test in $>; do \ | ||
| 17 | ./$$test; \ | ||
| 18 | done | ||
| 19 | |||
| 20 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/free/freenull.c b/src/regress/lib/libcrypto/free/freenull.c new file mode 100644 index 0000000000..8a3cd5de29 --- /dev/null +++ b/src/regress/lib/libcrypto/free/freenull.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* $OpenBSD: freenull.c,v 1.1 2017/05/02 04:03:06 beck Exp $ */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2017 Bob Beck <beck@openbsd.org> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted, provided that the above | ||
| 7 | * copyright notice and this permission notice appear in all copies. | ||
| 8 | * | ||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <openssl/asn1.h> | ||
| 19 | #include <openssl/x509.h> | ||
| 20 | #include <openssl/x509v3.h> | ||
| 21 | |||
| 22 | #include <err.h> | ||
| 23 | #include <stdio.h> | ||
| 24 | #include <string.h> | ||
| 25 | |||
| 26 | /* Make sure we do the right thing. Add here if you convert ones in tree */ | ||
| 27 | int | ||
| 28 | main(int argc, char **argv) | ||
| 29 | { | ||
| 30 | int failed = 0; | ||
| 31 | ASN1_OBJECT_free(NULL); | ||
| 32 | ASN1_INTEGER_free(NULL); | ||
| 33 | ASN1_OCTET_STRING_free(NULL); | ||
| 34 | NAME_CONSTRAINTS_free(NULL); | ||
| 35 | GENERAL_SUBTREE_free(NULL); | ||
| 36 | DIST_POINT_free(NULL); | ||
| 37 | X509_NAME_ENTRY_free(NULL); | ||
| 38 | GENERAL_NAME_free(NULL); | ||
| 39 | sk_GENERAL_NAME_pop_free(NULL, GENERAL_NAME_free); | ||
| 40 | sk_X509_NAME_ENTRY_pop_free(NULL, X509_NAME_ENTRY_free); | ||
| 41 | printf("PASS\n"); | ||
| 42 | return (failed); | ||
| 43 | } | ||
