]> sigrok.org Git - sigrok-cli.git/commitdiff
decode: stricter check for integer decoder options
authorGerhard Sittig <redacted>
Sat, 1 Dec 2018 11:26:34 +0000 (12:26 +0100)
committerGerhard Sittig <redacted>
Sat, 1 Dec 2018 11:26:34 +0000 (12:26 +0100)
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

index 2935286f4d5ef92d5acce0894cbed98bfece84cc..1ba5ef20ec80781de8ba3f3c0fa46a730ea6a7e3 100644 (file)
--- 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;