From: Nick Mathewson Date: Tue, 22 Oct 2019 18:16:23 +0000 (-0400) Subject: config validation: make the "old_options" argument const. X-Git-Tag: tor-0.4.3.1-alpha~264^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6bc2b41e54976abdafb464128890ae23584aeed7;p=thirdparty%2Ftor.git config validation: make the "old_options" argument const. We can't do this with the "options" argument yet, since several places in the code change those right now. --- diff --git a/src/app/config/config.c b/src/app/config/config.c index b804da62f2..55cc494485 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -843,7 +843,7 @@ static int parse_outbound_addresses(or_options_t *options, int validate_only, char **msg); static void config_maybe_load_geoip_files_(const or_options_t *options, const or_options_t *old_options); -static int options_validate_cb(void *old_options, void *options, +static int options_validate_cb(const void *old_options, void *options, char **msg); static void cleanup_protocol_warning_severity_level(void); static void set_protocol_warning_severity_level(int warning_severity); @@ -1227,7 +1227,8 @@ add_default_fallback_dir_servers,(void)) * user if we changed any dangerous ones. */ static int -validate_dir_servers(or_options_t *options, or_options_t *old_options) +validate_dir_servers(const or_options_t *options, + const or_options_t *old_options) { config_line_t *cl; @@ -3230,7 +3231,7 @@ compute_publishserverdescriptor(or_options_t *options) #define RECOMMENDED_MIN_CIRCUIT_BUILD_TIMEOUT (10) static int -options_validate_cb(void *old_options, void *options, char **msg) +options_validate_cb(const void *old_options, void *options, char **msg) { in_option_validation = 1; int rv = options_validate(old_options, options, msg); @@ -3430,7 +3431,7 @@ options_validate_single_onion(or_options_t *options, char **msg) * On error, tor_strdup an error explanation into *msg. */ STATIC int -options_validate(or_options_t *old_options, or_options_t *options, +options_validate(const or_options_t *old_options, or_options_t *options, char **msg) { config_line_t *cl; diff --git a/src/app/config/config.h b/src/app/config/config.h index 32ddc67652..dbba30e9c9 100644 --- a/src/app/config/config.h +++ b/src/app/config/config.h @@ -277,7 +277,7 @@ STATIC void port_cfg_free_(port_cfg_t *port); STATIC void or_options_free_(or_options_t *options); STATIC int options_validate_single_onion(or_options_t *options, char **msg); -STATIC int options_validate(or_options_t *old_options, +STATIC int options_validate(const or_options_t *old_options, or_options_t *options, char **msg); STATIC int parse_transport_line(const or_options_t *options, diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c index 3653deeee1..5c2e37490b 100644 --- a/src/app/config/statefile.c +++ b/src/app/config/statefile.c @@ -141,7 +141,7 @@ static const config_var_t state_vars_[] = { static int or_state_validate(or_state_t *state, char **msg); -static int or_state_validate_cb(void *old_options, +static int or_state_validate_cb(const void *old_options, void *options, char **msg); /** Magic value for or_state_t. */ @@ -268,7 +268,7 @@ validate_transports_in_state(or_state_t *state) } static int -or_state_validate_cb(void *old_state, void *state, char **msg) +or_state_validate_cb(const void *old_state, void *state, char **msg) { /* We don't use these; only options do. Still, we need to match that * signature. */ diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c index beeb03448c..94743fdb76 100644 --- a/src/feature/dirauth/shared_random_state.c +++ b/src/feature/dirauth/shared_random_state.c @@ -60,7 +60,7 @@ DUMMY_TYPECHECK_INSTANCE(sr_disk_state_t); #define SR_DISK_STATE_MAGIC 0x98AB1254 static int -disk_state_validate_cb(void *old_state, void *state, char **msg); +disk_state_validate_cb(const void *old_state, void *state, char **msg); /** Array of variables that are saved to disk as a persistent state. */ static const config_var_t state_vars[] = { @@ -344,7 +344,7 @@ disk_state_validate(const sr_disk_state_t *state) /** Validate the disk state (NOP for now). */ static int -disk_state_validate_cb(void *old_state, void *state, char **msg) +disk_state_validate_cb(const void *old_state, void *state, char **msg) { /* We don't use these; only options do. */ (void) old_state; diff --git a/src/lib/confmgt/confparse.h b/src/lib/confmgt/confparse.h index 628eb8927e..8d7278cb04 100644 --- a/src/lib/confmgt/confparse.h +++ b/src/lib/confmgt/confparse.h @@ -68,7 +68,7 @@ typedef struct config_deprecation_t { * config_dump(); later in our refactoring, it will be cleaned up and used * more generally. */ -typedef int (*validate_fn_t)(void *oldval, +typedef int (*validate_fn_t)(const void *oldval, void *newval, char **msg_out); diff --git a/src/test/test_confparse.c b/src/test/test_confparse.c index cfdcd34c3a..890c95d1c4 100644 --- a/src/test/test_confparse.c +++ b/src/test/test_confparse.c @@ -103,7 +103,7 @@ static config_deprecation_t test_deprecation_notes[] = { }; static int -test_validate_cb(void *old_options, void *options, char **msg) +test_validate_cb(const void *old_options, void *options, char **msg) { (void)old_options; (void)msg;