summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2024-10-11 12:10:12 +0000
committerjsing <>2024-10-11 12:10:12 +0000
commit32a16dec61a68ac61c650748402b46cfa49750da (patch)
tree5d93d782aa16ee3c9e57d0ac160c9672cb0c861c /src
parentbcdebcee92aa7480032512ae8141bae6467456cf (diff)
downloadopenbsd-32a16dec61a68ac61c650748402b46cfa49750da.tar.gz
openbsd-32a16dec61a68ac61c650748402b46cfa49750da.tar.bz2
openbsd-32a16dec61a68ac61c650748402b46cfa49750da.zip
Make ERR_str_{libraries,reasons,functs}[] const.
Provide err_load_const_strings(), which takes a const ERR_STRING_DATA * and does not perform a library error value fixup. Make ERR_str_*[] tables const. ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/err/err.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
index 4342efbdab..d3900a75f4 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.66 2024/10/11 11:58:53 jsing Exp $ */ 1/* $OpenBSD: err.c,v 1.67 2024/10/11 12:10:12 jsing 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 *
@@ -141,7 +141,7 @@ typedef struct err_state_st {
141} ERR_STATE; 141} ERR_STATE;
142 142
143#ifndef OPENSSL_NO_ERR 143#ifndef OPENSSL_NO_ERR
144static ERR_STRING_DATA ERR_str_libraries[] = { 144static const ERR_STRING_DATA ERR_str_libraries[] = {
145 {ERR_PACK(ERR_LIB_NONE,0,0), "unknown library"}, 145 {ERR_PACK(ERR_LIB_NONE,0,0), "unknown library"},
146 {ERR_PACK(ERR_LIB_SYS,0,0), "system library"}, 146 {ERR_PACK(ERR_LIB_SYS,0,0), "system library"},
147 {ERR_PACK(ERR_LIB_BN,0,0), "bignum routines"}, 147 {ERR_PACK(ERR_LIB_BN,0,0), "bignum routines"},
@@ -174,7 +174,7 @@ static ERR_STRING_DATA ERR_str_libraries[] = {
174 {0, NULL}, 174 {0, NULL},
175}; 175};
176 176
177static ERR_STRING_DATA ERR_str_functs[] = { 177static const ERR_STRING_DATA ERR_str_functs[] = {
178 {ERR_PACK(ERR_LIB_SYS,SYS_F_FOPEN, 0), "fopen"}, 178 {ERR_PACK(ERR_LIB_SYS,SYS_F_FOPEN, 0), "fopen"},
179 {ERR_PACK(ERR_LIB_SYS,SYS_F_CONNECT, 0), "connect"}, 179 {ERR_PACK(ERR_LIB_SYS,SYS_F_CONNECT, 0), "connect"},
180 {ERR_PACK(ERR_LIB_SYS,SYS_F_GETSERVBYNAME, 0), "getservbyname"}, 180 {ERR_PACK(ERR_LIB_SYS,SYS_F_GETSERVBYNAME, 0), "getservbyname"},
@@ -188,7 +188,7 @@ static ERR_STRING_DATA ERR_str_functs[] = {
188 {0, NULL}, 188 {0, NULL},
189}; 189};
190 190
191static ERR_STRING_DATA ERR_str_reasons[] = { 191static const ERR_STRING_DATA ERR_str_reasons[] = {
192 {ERR_R_SYS_LIB, "system lib"}, 192 {ERR_R_SYS_LIB, "system lib"},
193 {ERR_R_BN_LIB, "BN lib"}, 193 {ERR_R_BN_LIB, "BN lib"},
194 {ERR_R_RSA_LIB, "RSA lib"}, 194 {ERR_R_RSA_LIB, "RSA lib"},
@@ -609,7 +609,7 @@ ERR_get_state(void)
609static void 609static void
610err_load_strings(int lib, ERR_STRING_DATA *str) 610err_load_strings(int lib, ERR_STRING_DATA *str)
611{ 611{
612 while (str->error) { 612 while (str->error != 0) {
613 if (lib) 613 if (lib)
614 str->error |= ERR_PACK(lib, 0, 0); 614 str->error |= ERR_PACK(lib, 0, 0);
615 err_set_item(str); 615 err_set_item(str);
@@ -617,6 +617,15 @@ err_load_strings(int lib, ERR_STRING_DATA *str)
617 } 617 }
618} 618}
619 619
620static void
621err_load_const_strings(const ERR_STRING_DATA *str)
622{
623 while (str->error != 0) {
624 err_set_item(str);
625 str++;
626 }
627}
628
620static unsigned long 629static unsigned long
621get_error_values(int inc, int top, const char **file, int *line, 630get_error_values(int inc, int top, const char **file, int *line,
622 const char **data, int *flags) 631 const char **data, int *flags)
@@ -688,9 +697,9 @@ ERR_load_ERR_strings_internal(void)
688{ 697{
689 err_init_thread = pthread_self(); 698 err_init_thread = pthread_self();
690#ifndef OPENSSL_NO_ERR 699#ifndef OPENSSL_NO_ERR
691 err_load_strings(0, ERR_str_libraries); 700 err_load_const_strings(ERR_str_libraries);
692 err_load_strings(0, ERR_str_reasons); 701 err_load_const_strings(ERR_str_reasons);
693 err_load_strings(0, ERR_str_functs); 702 err_load_const_strings(ERR_str_functs);
694 build_SYS_str_reasons(); 703 build_SYS_str_reasons();
695 err_load_strings(ERR_LIB_SYS, SYS_str_reasons); 704 err_load_strings(ERR_LIB_SYS, SYS_str_reasons);
696#endif 705#endif
@@ -723,10 +732,7 @@ void
723ERR_load_const_strings(const ERR_STRING_DATA *str) 732ERR_load_const_strings(const ERR_STRING_DATA *str)
724{ 733{
725 ERR_load_ERR_strings(); 734 ERR_load_ERR_strings();
726 while (str->error) { 735 err_load_const_strings(str);
727 err_set_item(str);
728 str++;
729 }
730} 736}
731 737
732void 738void