aboutsummaryrefslogtreecommitdiff
path: root/src/util/config.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2023-10-13 08:41:25 +0200
committerChristian Grothoff <grothoff@gnunet.org>2023-10-13 08:41:25 +0200
commitc55be23e812f4add56711e1589d7aa5c9474917c (patch)
treef2120c49b27c8095bb2189c005d68c484842618f /src/util/config.c
parent6b48dae25df9deb9f60891f7b924136a61433d27 (diff)
downloadexchange-c55be23e812f4add56711e1589d7aa5c9474917c.tar.xz
-add sanity check
Diffstat (limited to 'src/util/config.c')
-rw-r--r--src/util/config.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/util/config.c b/src/util/config.c
index f00d11baa..d3804022b 100644
--- a/src/util/config.c
+++ b/src/util/config.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2020 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -392,7 +392,36 @@ parse_currencies_cb (void *cls,
return;
}
}
- /* FIXME: validate map only maps from decimal numbers to strings! */
+
+ {
+ /* validate map only maps from decimal numbers to strings! */
+ const char *str;
+ json_t *val;
+
+ json_object_foreach (cspec->map_alt_unit_names, str, val)
+ {
+ int idx;
+ char dummy;
+
+ if ( (1 != sscanf (str,
+ "%d%c",
+ &idx,
+ &dummy)) ||
+ (idx < -12) ||
+ (idx > 24) ||
+ (! json_is_string (val) ) )
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "ALT_UNIT_NAMES",
+ "invalid map entry detected");
+ cpc->failure = true;
+ json_decref (cspec->map_alt_unit_names);
+ cspec->map_alt_unit_names = NULL;
+ return;
+ }
+ }
+ }
}