diff options
author | schwarze <> | 2024-12-23 09:05:27 +0000 |
---|---|---|
committer | schwarze <> | 2024-12-23 09:05:27 +0000 |
commit | 4d64565b055a8c6210e8b50ccc27e0c6a5473ece (patch) | |
tree | 53d051d6c50bb3e5bbd2e0aa5a7e5f45b68f3f6d /src | |
parent | 91ac30d1f192fcfdf38e95c27804a08d2d07bbcb (diff) | |
download | openbsd-4d64565b055a8c6210e8b50ccc27e0c6a5473ece.tar.gz openbsd-4d64565b055a8c6210e8b50ccc27e0c6a5473ece.tar.bz2 openbsd-4d64565b055a8c6210e8b50ccc27e0c6a5473ece.zip |
Fix the error handling in X509V3_parse_list(3); it ignored failures
of the internal subroutine X509V3_add_value(), which could result
in silently losing part of the input data on memory exhaustion.
I independently rediscovered this bug while writing the documentation,
then noticed after fixing it that Zhou Qingyang <zhou1615 at umn dot edu>
fixed it in essentially the same way in OpenSSL 3 (commit bcd5645b
on Apr 11 02:05:19 2022 +0800), but it wasn't backported to the
OpenSSL 1.1.1 branch.
OK tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/x509/x509_utl.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/libcrypto/x509/x509_utl.c b/src/lib/libcrypto/x509/x509_utl.c index f327e9fca7..64dc1068b7 100644 --- a/src/lib/libcrypto/x509/x509_utl.c +++ b/src/lib/libcrypto/x509/x509_utl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_utl.c,v 1.22 2024/08/31 18:38:46 tb Exp $ */ | 1 | /* $OpenBSD: x509_utl.c,v 1.23 2024/12/23 09:05:27 schwarze 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. | 3 | * project. |
4 | */ | 4 | */ |
@@ -391,7 +391,8 @@ X509V3_parse_list(const char *line) | |||
391 | X509V3error(X509V3_R_INVALID_NULL_NAME); | 391 | X509V3error(X509V3_R_INVALID_NULL_NAME); |
392 | goto err; | 392 | goto err; |
393 | } | 393 | } |
394 | X509V3_add_value(ntmp, NULL, &values); | 394 | if (!X509V3_add_value(ntmp, NULL, &values)) |
395 | goto err; | ||
395 | } | 396 | } |
396 | break; | 397 | break; |
397 | 398 | ||
@@ -404,7 +405,8 @@ X509V3_parse_list(const char *line) | |||
404 | X509V3error(X509V3_R_INVALID_NULL_VALUE); | 405 | X509V3error(X509V3_R_INVALID_NULL_VALUE); |
405 | goto err; | 406 | goto err; |
406 | } | 407 | } |
407 | X509V3_add_value(ntmp, vtmp, &values); | 408 | if (!X509V3_add_value(ntmp, vtmp, &values)) |
409 | goto err; | ||
408 | ntmp = NULL; | 410 | ntmp = NULL; |
409 | q = p + 1; | 411 | q = p + 1; |
410 | } | 412 | } |
@@ -418,14 +420,16 @@ X509V3_parse_list(const char *line) | |||
418 | X509V3error(X509V3_R_INVALID_NULL_VALUE); | 420 | X509V3error(X509V3_R_INVALID_NULL_VALUE); |
419 | goto err; | 421 | goto err; |
420 | } | 422 | } |
421 | X509V3_add_value(ntmp, vtmp, &values); | 423 | if (!X509V3_add_value(ntmp, vtmp, &values)) |
424 | goto err; | ||
422 | } else { | 425 | } else { |
423 | ntmp = strip_spaces(q); | 426 | ntmp = strip_spaces(q); |
424 | if (!ntmp) { | 427 | if (!ntmp) { |
425 | X509V3error(X509V3_R_INVALID_NULL_NAME); | 428 | X509V3error(X509V3_R_INVALID_NULL_NAME); |
426 | goto err; | 429 | goto err; |
427 | } | 430 | } |
428 | X509V3_add_value(ntmp, NULL, &values); | 431 | if (!X509V3_add_value(ntmp, NULL, &values)) |
432 | goto err; | ||
429 | } | 433 | } |
430 | free(linebuf); | 434 | free(linebuf); |
431 | return values; | 435 | return values; |
@@ -434,7 +438,6 @@ X509V3_parse_list(const char *line) | |||
434 | free(linebuf); | 438 | free(linebuf); |
435 | sk_CONF_VALUE_pop_free(values, X509V3_conf_free); | 439 | sk_CONF_VALUE_pop_free(values, X509V3_conf_free); |
436 | return NULL; | 440 | return NULL; |
437 | |||
438 | } | 441 | } |
439 | LCRYPTO_ALIAS(X509V3_parse_list); | 442 | LCRYPTO_ALIAS(X509V3_parse_list); |
440 | 443 | ||