From 30ecd9641307fcbba78c89b5fda0fbeae31c7dce Mon Sep 17 00:00:00 2001 From: jsing <> Date: Thu, 22 Oct 2015 15:03:19 +0000 Subject: Restore previous behaviour and allow ASN1_{GENERALIZED,UTC,}TIME_set_string() to be called with a NULL pointer. Found the hard way by @kinichiro on github. ok beck@ --- src/lib/libcrypto/asn1/a_time_tm.c | 9 +++++++-- src/lib/libssl/src/crypto/asn1/a_time_tm.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c index 352b9159ee..e5ef007bb9 100644 --- a/src/lib/libcrypto/asn1/a_time_tm.c +++ b/src/lib/libcrypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.6 2015/10/19 16:32:37 beck Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.7 2015/10/22 15:03:19 jsing Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -216,17 +216,22 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) { int type; char *tmp; - + if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1) return (0); if (mode != 0 && mode != type) return (0); + + if (s == NULL) + return (1); + if ((tmp = strdup(str)) == NULL) return (0); free(s->data); s->data = tmp; s->length = strlen(tmp); s->type = type; + return (1); } diff --git a/src/lib/libssl/src/crypto/asn1/a_time_tm.c b/src/lib/libssl/src/crypto/asn1/a_time_tm.c index 352b9159ee..e5ef007bb9 100644 --- a/src/lib/libssl/src/crypto/asn1/a_time_tm.c +++ b/src/lib/libssl/src/crypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.6 2015/10/19 16:32:37 beck Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.7 2015/10/22 15:03:19 jsing Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -216,17 +216,22 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) { int type; char *tmp; - + if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1) return (0); if (mode != 0 && mode != type) return (0); + + if (s == NULL) + return (1); + if ((tmp = strdup(str)) == NULL) return (0); free(s->data); s->data = tmp; s->length = strlen(tmp); s->type = type; + return (1); } -- cgit v1.2.3-55-g6feb