From 030fbc721017350dbafec5fba71269472fe556c8 Mon Sep 17 00:00:00 2001
From: jsing <>
Date: Thu, 22 Oct 2015 14:10:55 +0000
Subject: 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.

---
 src/regress/lib/libcrypto/asn1/asn1time.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/regress/lib/libcrypto/asn1/asn1time.c b/src/regress/lib/libcrypto/asn1/asn1time.c
index 0334e49255..4db0f12769 100644
--- a/src/regress/lib/libcrypto/asn1/asn1time.c
+++ b/src/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;
 
-- 
cgit v1.2.3-55-g6feb