From b5c8f3a14ae5df5988f7491e4b65a1b3f60c089a Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sat, 1 Dec 2018 12:26:34 +0100 Subject: [PATCH] decode: stricter check for integer decoder options Tighten the check for integer type decoder options. Insist that the conversion must have consumed all of the input text. Early reject specs like "1m" or "8.0", but also unusual specs like "1 ". This shall avoid later confusion when "seemingly accepted" specs won't take effect during operation. --- decode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/decode.c b/decode.c index 2935286..1ba5ef2 100644 --- a/decode.c +++ b/decode.c @@ -54,8 +54,9 @@ static int opts_to_gvar(struct srd_decoder *dec, GHashTable *hash, if (g_variant_is_of_type(o->def, G_VARIANT_TYPE_STRING)) { gvar = g_variant_new_string(val_str); } else if (g_variant_is_of_type(o->def, G_VARIANT_TYPE_INT64)) { + conv = NULL; val_int = strtoll(val_str, &conv, 0); - if (!conv || conv == val_str) { + if (!conv || conv == val_str || *conv) { g_critical("Protocol decoder '%s' option '%s' " "requires a number.", dec->name, o->id); ret = FALSE; -- 2.11.4.GIT