diff options
| author | jan <> | 2023-03-27 09:15:45 +0000 |
|---|---|---|
| committer | jan <> | 2023-03-27 09:15:45 +0000 |
| commit | a1ba7edeaa4500f47680c5e16b40d8efa2802629 (patch) | |
| tree | e19171fe3b4271a70576a7e1198652297099d72c /src/lib/libcrypto/err/err.c | |
| parent | bb7ef4dee10369d5d5ef4c62545361f05798ff2d (diff) | |
| download | openbsd-a1ba7edeaa4500f47680c5e16b40d8efa2802629.tar.gz openbsd-a1ba7edeaa4500f47680c5e16b40d8efa2802629.tar.bz2 openbsd-a1ba7edeaa4500f47680c5e16b40d8efa2802629.zip | |
Avoid errno is EINVAL after OpenSSL initialization
ok tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index 403fcd4607..2eca16d77c 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: err.c,v 1.50 2022/12/26 07:18:52 jmc Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.51 2023/03/27 09:15:45 jan Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -580,6 +580,7 @@ build_SYS_str_reasons(void) | |||
| 580 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; | 580 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; |
| 581 | int i; | 581 | int i; |
| 582 | static int init = 1; | 582 | static int init = 1; |
| 583 | int save_errno; | ||
| 583 | 584 | ||
| 584 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); | 585 | CRYPTO_r_lock(CRYPTO_LOCK_ERR); |
| 585 | if (!init) { | 586 | if (!init) { |
| @@ -594,6 +595,8 @@ build_SYS_str_reasons(void) | |||
| 594 | return; | 595 | return; |
| 595 | } | 596 | } |
| 596 | 597 | ||
| 598 | /* strerror(3) will set errno to EINVAL when i is an unknown errno. */ | ||
| 599 | save_errno = errno; | ||
| 597 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { | 600 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { |
| 598 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; | 601 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; |
| 599 | 602 | ||
| @@ -610,6 +613,7 @@ build_SYS_str_reasons(void) | |||
| 610 | if (str->string == NULL) | 613 | if (str->string == NULL) |
| 611 | str->string = "unknown"; | 614 | str->string = "unknown"; |
| 612 | } | 615 | } |
| 616 | errno = save_errno; | ||
| 613 | 617 | ||
| 614 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, | 618 | /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, |
| 615 | * as required by ERR_load_strings. */ | 619 | * as required by ERR_load_strings. */ |
