summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2015-10-22 14:10:55 +0000
committerjsing <jsing@openbsd.org>2015-10-22 14:10:55 +0000
commit986aa51e16c9604760ccfe33242d452a242aee43 (patch)
tree61a9db6a83019186ada3f9dbf3ba86dd7c102290
parentFix case where we wanted to test ASN1_TIME_set_string() but were testing (diff)
downloadwireguard-openbsd-986aa51e16c9604760ccfe33242d452a242aee43.tar.xz
wireguard-openbsd-986aa51e16c9604760ccfe33242d452a242aee43.zip
Extend tests to call ASN1_{GENERALIZED,UTC,}TIME_set_string() with a NULL
pointer - because, you know, you might want to set a string on a NULL object. The previous implementation apparently allowed this as a way of testing if the string was valid... probably because the *_check() functions are only useable after the string has already been set.
-rw-r--r--regress/lib/libcrypto/asn1/asn1time.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/regress/lib/libcrypto/asn1/asn1time.c b/regress/lib/libcrypto/asn1/asn1time.c
index 0334e492557..4db0f12769b 100644
--- a/regress/lib/libcrypto/asn1/asn1time.c
+++ b/regress/lib/libcrypto/asn1/asn1time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asn1time.c,v 1.5 2015/10/22 13:58:47 jsing Exp $ */
+/* $OpenBSD: asn1time.c,v 1.6 2015/10/22 14:10:55 jsing Exp $ */
/*
* Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
*
@@ -236,6 +236,12 @@ asn1_gentime_test(int test_no, struct asn1_time_test *att)
int failure = 1;
int len;
+ if (ASN1_GENERALIZEDTIME_set_string(NULL, att->str) != 1) {
+ fprintf(stderr, "FAIL: test %i - failed to set string '%s'\n",
+ test_no, att->str);
+ goto done;
+ }
+
if ((gt = ASN1_GENERALIZEDTIME_new()) == NULL)
goto done;
@@ -293,6 +299,12 @@ asn1_utctime_test(int test_no, struct asn1_time_test *att)
int failure = 1;
int len;
+ if (ASN1_UTCTIME_set_string(NULL, att->str) != 1) {
+ fprintf(stderr, "FAIL: test %i - failed to set string '%s'\n",
+ test_no, att->str);
+ goto done;
+ }
+
if ((ut = ASN1_UTCTIME_new()) == NULL)
goto done;
@@ -347,6 +359,12 @@ asn1_time_test(int test_no, struct asn1_time_test *att, int type)
ASN1_TIME *t = NULL;
int failure = 1;
+ if (ASN1_TIME_set_string(NULL, att->str) != 1) {
+ fprintf(stderr, "FAIL: test %i - failed to set string '%s'\n",
+ test_no, att->str);
+ goto done;
+ }
+
if ((t = ASN1_TIME_new()) == NULL)
goto done;