summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2015-07-20 15:43:23 +0000
committermiod <>2015-07-20 15:43:23 +0000
commit5ed4f59b4f0ac21a8c65bf523684fae22f188d90 (patch)
treea0984651c39136da3b989877a4aa3734d2a8e692
parent6cfa8128efb13a4c9685a98c10b59f1c880a72c0 (diff)
downloadopenbsd-5ed4f59b4f0ac21a8c65bf523684fae22f188d90.tar.gz
openbsd-5ed4f59b4f0ac21a8c65bf523684fae22f188d90.tar.bz2
openbsd-5ed4f59b4f0ac21a8c65bf523684fae22f188d90.zip
Use V_ASN1_UNDEF instead of -1.
Make sure ASN1_primitive_new() will return NULL in *pval in all error situations. ok bcook@ doug@
-rw-r--r--src/lib/libcrypto/asn1/tasn_new.c14
-rw-r--r--src/lib/libssl/src/crypto/asn1/tasn_new.c14
2 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_new.c b/src/lib/libcrypto/asn1/tasn_new.c
index 132df07637..986e5811b6 100644
--- a/src/lib/libcrypto/asn1/tasn_new.c
+++ b/src/lib/libcrypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.15 2015/07/20 15:43:23 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -313,7 +313,7 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
313 } 313 }
314 314
315 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 315 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
316 utype = -1; 316 utype = V_ASN1_UNDEF;
317 else 317 else
318 utype = it->utype; 318 utype = it->utype;
319 switch (utype) { 319 switch (utype) {
@@ -331,10 +331,10 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
331 331
332 case V_ASN1_ANY: 332 case V_ASN1_ANY:
333 typ = malloc(sizeof(ASN1_TYPE)); 333 typ = malloc(sizeof(ASN1_TYPE));
334 if (!typ) 334 if (typ != NULL) {
335 return 0; 335 typ->value.ptr = NULL;
336 typ->value.ptr = NULL; 336 typ->type = V_ASN1_UNDEF;
337 typ->type = -1; 337 }
338 *pval = (ASN1_VALUE *)typ; 338 *pval = (ASN1_VALUE *)typ;
339 break; 339 break;
340 340
@@ -364,7 +364,7 @@ asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
364 return; 364 return;
365 } 365 }
366 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 366 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
367 utype = -1; 367 utype = V_ASN1_UNDEF;
368 else 368 else
369 utype = it->utype; 369 utype = it->utype;
370 if (utype == V_ASN1_BOOLEAN) 370 if (utype == V_ASN1_BOOLEAN)
diff --git a/src/lib/libssl/src/crypto/asn1/tasn_new.c b/src/lib/libssl/src/crypto/asn1/tasn_new.c
index 132df07637..986e5811b6 100644
--- a/src/lib/libssl/src/crypto/asn1/tasn_new.c
+++ b/src/lib/libssl/src/crypto/asn1/tasn_new.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_new.c,v 1.14 2015/02/14 15:23:57 miod Exp $ */ 1/* $OpenBSD: tasn_new.c,v 1.15 2015/07/20 15:43:23 miod Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -313,7 +313,7 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
313 } 313 }
314 314
315 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 315 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
316 utype = -1; 316 utype = V_ASN1_UNDEF;
317 else 317 else
318 utype = it->utype; 318 utype = it->utype;
319 switch (utype) { 319 switch (utype) {
@@ -331,10 +331,10 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
331 331
332 case V_ASN1_ANY: 332 case V_ASN1_ANY:
333 typ = malloc(sizeof(ASN1_TYPE)); 333 typ = malloc(sizeof(ASN1_TYPE));
334 if (!typ) 334 if (typ != NULL) {
335 return 0; 335 typ->value.ptr = NULL;
336 typ->value.ptr = NULL; 336 typ->type = V_ASN1_UNDEF;
337 typ->type = -1; 337 }
338 *pval = (ASN1_VALUE *)typ; 338 *pval = (ASN1_VALUE *)typ;
339 break; 339 break;
340 340
@@ -364,7 +364,7 @@ asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
364 return; 364 return;
365 } 365 }
366 if (!it || (it->itype == ASN1_ITYPE_MSTRING)) 366 if (!it || (it->itype == ASN1_ITYPE_MSTRING))
367 utype = -1; 367 utype = V_ASN1_UNDEF;
368 else 368 else
369 utype = it->utype; 369 utype = it->utype;
370 if (utype == V_ASN1_BOOLEAN) 370 if (utype == V_ASN1_BOOLEAN)