diff options
-rw-r--r-- | src/lib/libcrypto/x509v3/v3_ocsp.c | 14 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/x509v3/v3_ocsp.c | 14 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_ocsp.c b/src/lib/libcrypto/x509v3/v3_ocsp.c index d606240b12..1d9c8a8513 100644 --- a/src/lib/libcrypto/x509v3/v3_ocsp.c +++ b/src/lib/libcrypto/x509v3/v3_ocsp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: v3_ocsp.c,v 1.10 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: v3_ocsp.c,v 1.11 2015/02/15 08:45:27 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -242,21 +242,23 @@ d2i_ocsp_nonce(void *a, const unsigned char **pp, long length) | |||
242 | ASN1_OCTET_STRING *os, **pos; | 242 | ASN1_OCTET_STRING *os, **pos; |
243 | 243 | ||
244 | pos = a; | 244 | pos = a; |
245 | if (!pos || !*pos) | 245 | if (pos == NULL || *pos == NULL) { |
246 | os = ASN1_OCTET_STRING_new(); | 246 | os = ASN1_OCTET_STRING_new(); |
247 | else | 247 | if (os == NULL) |
248 | goto err; | ||
249 | } else | ||
248 | os = *pos; | 250 | os = *pos; |
249 | if (!ASN1_OCTET_STRING_set(os, *pp, length)) | 251 | if (ASN1_OCTET_STRING_set(os, *pp, length) == 0) |
250 | goto err; | 252 | goto err; |
251 | 253 | ||
252 | *pp += length; | 254 | *pp += length; |
253 | 255 | ||
254 | if (pos) | 256 | if (pos != NULL) |
255 | *pos = os; | 257 | *pos = os; |
256 | return os; | 258 | return os; |
257 | 259 | ||
258 | err: | 260 | err: |
259 | if (os && (!pos || (*pos != os))) | 261 | if (pos == NULL || *pos != os) |
260 | M_ASN1_OCTET_STRING_free(os); | 262 | M_ASN1_OCTET_STRING_free(os); |
261 | OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); | 263 | OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); |
262 | return NULL; | 264 | return NULL; |
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c b/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c index d606240b12..1d9c8a8513 100644 --- a/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c +++ b/src/lib/libssl/src/crypto/x509v3/v3_ocsp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: v3_ocsp.c,v 1.10 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: v3_ocsp.c,v 1.11 2015/02/15 08:45:27 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -242,21 +242,23 @@ d2i_ocsp_nonce(void *a, const unsigned char **pp, long length) | |||
242 | ASN1_OCTET_STRING *os, **pos; | 242 | ASN1_OCTET_STRING *os, **pos; |
243 | 243 | ||
244 | pos = a; | 244 | pos = a; |
245 | if (!pos || !*pos) | 245 | if (pos == NULL || *pos == NULL) { |
246 | os = ASN1_OCTET_STRING_new(); | 246 | os = ASN1_OCTET_STRING_new(); |
247 | else | 247 | if (os == NULL) |
248 | goto err; | ||
249 | } else | ||
248 | os = *pos; | 250 | os = *pos; |
249 | if (!ASN1_OCTET_STRING_set(os, *pp, length)) | 251 | if (ASN1_OCTET_STRING_set(os, *pp, length) == 0) |
250 | goto err; | 252 | goto err; |
251 | 253 | ||
252 | *pp += length; | 254 | *pp += length; |
253 | 255 | ||
254 | if (pos) | 256 | if (pos != NULL) |
255 | *pos = os; | 257 | *pos = os; |
256 | return os; | 258 | return os; |
257 | 259 | ||
258 | err: | 260 | err: |
259 | if (os && (!pos || (*pos != os))) | 261 | if (pos == NULL || *pos != os) |
260 | M_ASN1_OCTET_STRING_free(os); | 262 | M_ASN1_OCTET_STRING_free(os); |
261 | OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); | 263 | OCSPerr(OCSP_F_D2I_OCSP_NONCE, ERR_R_MALLOC_FAILURE); |
262 | return NULL; | 264 | return NULL; |