CVSROOT:        /cvs
Module name:    src
Changes by:     t...@cvs.openbsd.org    2024/06/24 00:43:23

Modified files:
        lib/libcrypto  : Makefile cpt_err.c 
        lib/libcrypto/asn1: asn1_err.c 
        lib/libcrypto/bio: bio_err.c 
        lib/libcrypto/bn: bn_err.c 
        lib/libcrypto/buffer: buf_err.c 
        lib/libcrypto/cms: cms_err.c 
        lib/libcrypto/conf: conf_err.c 
        lib/libcrypto/ct: ct_err.c 
        lib/libcrypto/dh: dh_err.c 
        lib/libcrypto/dsa: dsa_err.c 
        lib/libcrypto/ec: ec_err.c 
        lib/libcrypto/err: err.c 
        lib/libcrypto/evp: evp_err.c 
        lib/libcrypto/kdf: kdf_err.c 
        lib/libcrypto/objects: obj_err.c 
        lib/libcrypto/ocsp: ocsp_err.c 
        lib/libcrypto/pem: pem_err.c 
        lib/libcrypto/pkcs12: pk12err.c 
        lib/libcrypto/pkcs7: pkcs7err.c 
        lib/libcrypto/rand: rand_err.c 
        lib/libcrypto/rsa: rsa_err.c 
        lib/libcrypto/ts: ts_err.c 
        lib/libcrypto/ui: ui_err.c 
        lib/libcrypto/x509: x509_err.c 
Added files:
        lib/libcrypto/err: err_local.h 

Log message:
libcrypto: constify most error string tables

These constitute the bulk of the remaining global mutable state in
libcrypto. This commit moves most of them into data.rel.ro, leaving
out ERR_str_{functs,libraries,reasons} (which require a slightly
different approach) and SYS_str_reasons which is populated on startup.

The main observation is that if ERR_load_strings() is called with a 0 lib
argument, the ERR_STRING_DATA argument is not actually modified. We could
use this fact to cast away const on the caller side and be done with it.
We can make this cleaner by adding a helper ERR_load_const_strings() which
explicitly avoids the assignment to str->error overriding the error code
already set in the table.

In order for this to work, we need to sprinkle some const in err/err.c.
CMS called ERR_load_strings() with non-0 lib argument, but this didn't
actually modify the error data since it ored in the value already stored
in the table.

Annoyingly, we need to cast const away once, namely in the call to
lh_insert() in int_err_set_item(). Fixing this would require changing
the public API and is going to be tricky since it requires that the
LHASH_DOALL_FN_* types adjust.

ok jsing

Reply via email to