-/* $OpenBSD: err.c,v 1.66 2024/10/11 11:58:53 jsing Exp $ */
+/* $OpenBSD: err.c,v 1.67 2024/10/11 12:10:12 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
} ERR_STATE;
#ifndef OPENSSL_NO_ERR
-static ERR_STRING_DATA ERR_str_libraries[] = {
+static const ERR_STRING_DATA ERR_str_libraries[] = {
{ERR_PACK(ERR_LIB_NONE,0,0), "unknown library"},
{ERR_PACK(ERR_LIB_SYS,0,0), "system library"},
{ERR_PACK(ERR_LIB_BN,0,0), "bignum routines"},
{0, NULL},
};
-static ERR_STRING_DATA ERR_str_functs[] = {
+static const ERR_STRING_DATA ERR_str_functs[] = {
{ERR_PACK(ERR_LIB_SYS,SYS_F_FOPEN, 0), "fopen"},
{ERR_PACK(ERR_LIB_SYS,SYS_F_CONNECT, 0), "connect"},
{ERR_PACK(ERR_LIB_SYS,SYS_F_GETSERVBYNAME, 0), "getservbyname"},
{0, NULL},
};
-static ERR_STRING_DATA ERR_str_reasons[] = {
+static const ERR_STRING_DATA ERR_str_reasons[] = {
{ERR_R_SYS_LIB, "system lib"},
{ERR_R_BN_LIB, "BN lib"},
{ERR_R_RSA_LIB, "RSA lib"},
static void
err_load_strings(int lib, ERR_STRING_DATA *str)
{
- while (str->error) {
+ while (str->error != 0) {
if (lib)
str->error |= ERR_PACK(lib, 0, 0);
err_set_item(str);
}
}
+static void
+err_load_const_strings(const ERR_STRING_DATA *str)
+{
+ while (str->error != 0) {
+ err_set_item(str);
+ str++;
+ }
+}
+
static unsigned long
get_error_values(int inc, int top, const char **file, int *line,
const char **data, int *flags)
{
err_init_thread = pthread_self();
#ifndef OPENSSL_NO_ERR
- err_load_strings(0, ERR_str_libraries);
- err_load_strings(0, ERR_str_reasons);
- err_load_strings(0, ERR_str_functs);
+ err_load_const_strings(ERR_str_libraries);
+ err_load_const_strings(ERR_str_reasons);
+ err_load_const_strings(ERR_str_functs);
build_SYS_str_reasons();
err_load_strings(ERR_LIB_SYS, SYS_str_reasons);
#endif
ERR_load_const_strings(const ERR_STRING_DATA *str)
{
ERR_load_ERR_strings();
- while (str->error) {
- err_set_item(str);
- str++;
- }
+ err_load_const_strings(str);
}
void