From 9cc23e66e95df689d0bacc9ae4f8bd9907a56666 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 31 Aug 2024 09:39:31 +0000 Subject: [PATCH] const correct uses of CONF_METHOD While not all of this is strictly needed, it was simply incorrect. This way another global which was modifiable for no good reason becomes const. ok beck jsing --- lib/libcrypto/conf/conf.h | 8 ++++---- lib/libcrypto/conf/conf_def.c | 8 ++++---- lib/libcrypto/conf/conf_lib.c | 6 +++--- lib/libcrypto/conf/conf_local.h | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/libcrypto/conf/conf.h b/lib/libcrypto/conf/conf.h index f5c449e5475..7ddb33ccd43 100644 --- a/lib/libcrypto/conf/conf.h +++ b/lib/libcrypto/conf/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.21 2024/08/31 09:36:38 tb Exp $ */ +/* $OpenBSD: conf.h,v 1.22 2024/08/31 09:39:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -126,12 +126,12 @@ void OPENSSL_no_config(void); If that wasn't the case, the above functions would have been replaced */ struct conf_st { - CONF_METHOD *meth; + const CONF_METHOD *meth; LHASH_OF(CONF_VALUE) *data; }; -CONF *NCONF_new(CONF_METHOD *meth); -CONF_METHOD *NCONF_default(void); +CONF *NCONF_new(const CONF_METHOD *meth); +const CONF_METHOD *NCONF_default(void); void NCONF_free(CONF *conf); void NCONF_free_data(CONF *conf); diff --git a/lib/libcrypto/conf/conf_def.c b/lib/libcrypto/conf/conf_def.c index 5698bfdbaf5..26e273c841d 100644 --- a/lib/libcrypto/conf/conf_def.c +++ b/lib/libcrypto/conf/conf_def.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_def.c,v 1.41 2024/08/31 09:36:38 tb Exp $ */ +/* $OpenBSD: conf_def.c,v 1.42 2024/08/31 09:39:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,7 +81,7 @@ static char *scan_dquote(CONF *conf, char *p); #define scan_esc(conf,p) (((IS_EOF((conf),(p)[1]))?((p)+1):((p)+2))) static CONF * -def_create(CONF_METHOD *meth) +def_create(const CONF_METHOD *meth) { CONF *ret; @@ -634,7 +634,7 @@ def_to_int(const CONF *conf, char c) return c - '0'; } -static CONF_METHOD default_method = { +static const CONF_METHOD default_method = { .name = "OpenSSL default", .create = def_create, .init = def_init_default, @@ -647,7 +647,7 @@ static CONF_METHOD default_method = { .load = def_load, }; -CONF_METHOD * +const CONF_METHOD * NCONF_default(void) { return &default_method; diff --git a/lib/libcrypto/conf/conf_lib.c b/lib/libcrypto/conf/conf_lib.c index ccd09c02586..d7a2870520a 100644 --- a/lib/libcrypto/conf/conf_lib.c +++ b/lib/libcrypto/conf/conf_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_lib.c,v 1.21 2024/08/31 09:29:03 tb Exp $ */ +/* $OpenBSD: conf_lib.c,v 1.22 2024/08/31 09:39:31 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2000. */ @@ -64,7 +64,7 @@ #include "conf_local.h" -static CONF_METHOD *default_CONF_method = NULL; +static const CONF_METHOD *default_CONF_method = NULL; /* Init a 'CONF' structure from an old LHASH */ @@ -202,7 +202,7 @@ LCRYPTO_ALIAS(CONF_free); by the "CONF classic" functions, for consistency. */ CONF * -NCONF_new(CONF_METHOD *meth) +NCONF_new(const CONF_METHOD *meth) { CONF *ret; diff --git a/lib/libcrypto/conf/conf_local.h b/lib/libcrypto/conf/conf_local.h index c991f0629b9..f2c755bbf69 100644 --- a/lib/libcrypto/conf/conf_local.h +++ b/lib/libcrypto/conf/conf_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf_local.h,v 1.3 2024/08/31 09:29:03 tb Exp $ */ +/* $OpenBSD: conf_local.h,v 1.4 2024/08/31 09:39:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ __BEGIN_HIDDEN_DECLS struct conf_method_st { const char *name; - CONF *(*create)(CONF_METHOD *meth); + CONF *(*create)(const CONF_METHOD *meth); int (*init)(CONF *conf); int (*destroy)(CONF *conf); int (*destroy_data)(CONF *conf); -- 2.20.1