summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2015-10-22 15:03:19 +0000
committerjsing <>2015-10-22 15:03:19 +0000
commit30ecd9641307fcbba78c89b5fda0fbeae31c7dce (patch)
treefb168d3b6b55542e7052f026763a325ace593cdf /src/lib
parent030fbc721017350dbafec5fba71269472fe556c8 (diff)
downloadopenbsd-30ecd9641307fcbba78c89b5fda0fbeae31c7dce.tar.gz
openbsd-30ecd9641307fcbba78c89b5fda0fbeae31c7dce.tar.bz2
openbsd-30ecd9641307fcbba78c89b5fda0fbeae31c7dce.zip
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@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c9
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_time_tm.c9
2 files changed, 14 insertions, 4 deletions
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 @@
1/* $OpenBSD: a_time_tm.c,v 1.6 2015/10/19 16:32:37 beck Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.7 2015/10/22 15:03:19 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -216,17 +216,22 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode)
216{ 216{
217 int type; 217 int type;
218 char *tmp; 218 char *tmp;
219 219
220 if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1) 220 if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1)
221 return (0); 221 return (0);
222 if (mode != 0 && mode != type) 222 if (mode != 0 && mode != type)
223 return (0); 223 return (0);
224
225 if (s == NULL)
226 return (1);
227
224 if ((tmp = strdup(str)) == NULL) 228 if ((tmp = strdup(str)) == NULL)
225 return (0); 229 return (0);
226 free(s->data); 230 free(s->data);
227 s->data = tmp; 231 s->data = tmp;
228 s->length = strlen(tmp); 232 s->length = strlen(tmp);
229 s->type = type; 233 s->type = type;
234
230 return (1); 235 return (1);
231} 236}
232 237
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 @@
1/* $OpenBSD: a_time_tm.c,v 1.6 2015/10/19 16:32:37 beck Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.7 2015/10/22 15:03:19 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -216,17 +216,22 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode)
216{ 216{
217 int type; 217 int type;
218 char *tmp; 218 char *tmp;
219 219
220 if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1) 220 if ((type = asn1_time_parse(str, strlen(str), NULL, mode)) == -1)
221 return (0); 221 return (0);
222 if (mode != 0 && mode != type) 222 if (mode != 0 && mode != type)
223 return (0); 223 return (0);
224
225 if (s == NULL)
226 return (1);
227
224 if ((tmp = strdup(str)) == NULL) 228 if ((tmp = strdup(str)) == NULL)
225 return (0); 229 return (0);
226 free(s->data); 230 free(s->data);
227 s->data = tmp; 231 s->data = tmp;
228 s->length = strlen(tmp); 232 s->length = strlen(tmp);
229 s->type = type; 233 s->type = type;
234
230 return (1); 235 return (1);
231} 236}
232 237