From 75875b67bf8a5a4142a5faaaab7a434a7b68772c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 15 Nov 2019 15:13:02 -0800 Subject: settings: check value in settings_apply_desc_generators() Use setting_desc_check() before storing a value. --- src/settings.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/settings.c b/src/settings.c index c7419e1..e5560b0 100644 --- a/src/settings.c +++ b/src/settings.c @@ -191,20 +191,28 @@ int settings_apply_desc_generators(const settings_t *settings, const setting_des for (i = 0; i < n_generators; i++) { const setting_desc_generator_t *g = &generators[i]; const char *value; + setting_desc_t *desc; + + desc = g->func(setup_context); + if (!desc) + return -ENOMEM; value = settings_get_value(settings, g->key); if (value) { + int r; + + r = setting_desc_check(desc, value); + setting_desc_free(desc); + if (r < 0) + return r; + if (g->value_ptr) *g->value_ptr = value; continue; } - next = g->func(setup_context); - if (!next) - return -ENOMEM; - - *next_setting = next; + *next_setting = desc; return 1; } -- cgit v1.2.3