-/* $OpenBSD: err.c,v 1.50 2022/12/26 07:18:52 jmc Exp $ */
+/* $OpenBSD: err.c,v 1.51 2023/03/27 09:15:45 jan Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
int i;
static int init = 1;
+ int save_errno;
CRYPTO_r_lock(CRYPTO_LOCK_ERR);
if (!init) {
return;
}
+ /* strerror(3) will set errno to EINVAL when i is an unknown errno. */
+ save_errno = errno;
for (i = 1; i <= NUM_SYS_STR_REASONS; i++) {
ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
if (str->string == NULL)
str->string = "unknown";
}
+ errno = save_errno;
/* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
* as required by ERR_load_strings. */