summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjan <>2023-03-27 09:15:45 +0000
committerjan <>2023-03-27 09:15:45 +0000
commit9451ef4be9b27112ac4a15b1d975620ec836003f (patch)
treee19171fe3b4271a70576a7e1198652297099d72c /src
parent04102b8382e69b88db65e1e30a569dcca0ac8daf (diff)
downloadopenbsd-9451ef4be9b27112ac4a15b1d975620ec836003f.tar.gz
openbsd-9451ef4be9b27112ac4a15b1d975620ec836003f.tar.bz2
openbsd-9451ef4be9b27112ac4a15b1d975620ec836003f.zip
Avoid errno is EINVAL after OpenSSL initialization
ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/err/err.c6
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. */