From 5c9030129dd438d32d9bc9a0351540238dc57356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 30 Oct 2020 11:00:40 +0100 Subject: [PATCH] =?UTF-8?q?module/script:=20use=20NULL=20terminated=20?= =?UTF-8?q?=E2=80=98value=E2=80=99=20when=20converting=20to=20int/bool/flo?= =?UTF-8?q?at?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/script.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/modules/script.c b/modules/script.c index b3e3fd4..1ee4b72 100644 --- a/modules/script.c +++ b/modules/script.c @@ -108,20 +108,14 @@ process_line(struct module *mod, const char *line, size_t len) if (type_len == 6 && memcmp(type, "string", 6) == 0) tag = tag_new_string(mod, name, value); - else if (type_len == 3 && memcmp(type, "int", 3) == 0) { - long value = strtol(_value, NULL, 0); - tag = tag_new_int(mod, name, value); - } + else if (type_len == 3 && memcmp(type, "int", 3) == 0) + tag = tag_new_int(mod, name, strtol(value, NULL, 0)); - else if (type_len == 4 && memcmp(type, "bool", 4) == 0) { - bool value = strtol(_value, NULL, 0); - tag = tag_new_bool(mod, name, value); - } + else if (type_len == 4 && memcmp(type, "bool", 4) == 0) + tag = tag_new_bool(mod, name, strtol(value, NULL, 0)); - else if (type_len == 5 && memcmp(type, "float", 5) == 0) { - double value = strtod(_value, NULL); - tag = tag_new_float(mod, name, value); - } + else if (type_len == 5 && memcmp(type, "float", 5) == 0) + tag = tag_new_float(mod, name, strtod(value, NULL)); else if ((type_len > 6 && memcmp(type, "range:", 6) == 0) || (type_len > 9 && memcmp(type, "realtime:", 9 == 0))) @@ -160,8 +154,7 @@ process_line(struct module *mod, const char *line, size_t len) goto bad_tag; } - long value = strtol(_value, NULL, 0); - tag = tag_new_int_range(mod, name, value, start, end); + tag = tag_new_int_range(mod, name, strtol(value, NULL, 0), start, end); } else {