From: Gerhard Sittig Date: Sat, 1 Dec 2018 11:26:34 +0000 (+0100) Subject: decode: stricter check for integer decoder options X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b5c8f3a14ae5df5988f7491e4b65a1b3f60c089a;p=sigrok-cli.git 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. --- 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;