diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index 25fbb03875..f03a4431e7 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.75 2024/11/02 12:46:36 tb Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.76 2025/05/20 09:25:40 tb 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 | * |
| @@ -484,33 +484,27 @@ err_build_SYS_str_reasons(void) | |||
| 484 | { | 484 | { |
| 485 | /* malloc cannot be used here, use static storage instead */ | 485 | /* malloc cannot be used here, use static storage instead */ |
| 486 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; | 486 | static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; |
| 487 | const char *errstr; | ||
| 487 | int save_errno; | 488 | int save_errno; |
| 488 | int i; | 489 | int i; |
| 489 | 490 | ||
| 490 | /* strerror(3) will set errno to EINVAL when i is an unknown errno. */ | 491 | /* strerror(3) will set errno to EINVAL when i is an unknown errno. */ |
| 491 | save_errno = errno; | 492 | save_errno = errno; |
| 492 | for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { | 493 | for (i = 0; i < NUM_SYS_STR_REASONS; i++) { |
| 493 | ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; | 494 | ERR_STRING_DATA *str = &SYS_str_reasons[i]; |
| 494 | 495 | ||
| 495 | str->error = (unsigned long)i; | 496 | str->error = i + 1; |
| 496 | if (str->string == NULL) { | 497 | str->string = "unknown"; |
| 497 | char (*dest)[LEN_SYS_STR_REASON] = | 498 | |
| 498 | &(strerror_tab[i - 1]); | 499 | if ((errstr = strerror((int)str->error)) != NULL) { |
| 499 | const char *src = strerror(i); | 500 | strlcpy(strerror_tab[i], errstr, sizeof(strerror_tab[i])); |
| 500 | if (src != NULL) { | 501 | str->string = strerror_tab[i]; |
| 501 | strlcpy(*dest, src, sizeof *dest); | ||
| 502 | str->string = *dest; | ||
| 503 | } | ||
| 504 | } | 502 | } |
| 505 | if (str->string == NULL) | ||
| 506 | str->string = "unknown"; | ||
| 507 | } | 503 | } |
| 508 | errno = save_errno; | 504 | errno = save_errno; |
| 509 | 505 | ||
| 510 | /* | 506 | SYS_str_reasons[NUM_SYS_STR_REASONS].error = 0; |
| 511 | * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, | 507 | SYS_str_reasons[NUM_SYS_STR_REASONS].string = NULL; |
| 512 | * as required by ERR_load_strings. | ||
| 513 | */ | ||
| 514 | } | 508 | } |
| 515 | #endif | 509 | #endif |
| 516 | 510 | ||
