]> sigrok.org Git - libsigrok.git/commitdiff
don't accept numbers as probe identifiers in trigger string
authorBert Vermeulen <redacted>
Mon, 8 Oct 2012 21:56:06 +0000 (23:56 +0200)
committerBert Vermeulen <redacted>
Sun, 14 Oct 2012 12:59:07 +0000 (14:59 +0200)
Only the probe name, as supplied by the device driver, is accepted.

strutil.c

index 8abc556ec807875a0027c7e3a944d5d533436e8d..0ddeae0973690ca2ec6535a7758f56a75d34de34 100644 (file)
--- a/strutil.c
+++ b/strutil.c
@@ -214,24 +214,19 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
 
        tokens = g_strsplit(triggerstring, ",", max_probes);
        for (i = 0; tokens[i]; i++) {
-               if (tokens[i][0] < '0' || tokens[i][0] > '9') {
-                       /* Named probe */
-                       probenum = 0;
-                       for (l = sdi->probes; l; l = l->next) {
-                               probe = (struct sr_probe *)l->data;
-                               if (probe->enabled
-                                   && !strncmp(probe->name, tokens[i],
-                                               strlen(probe->name))) {
-                                       probenum = probe->index;
-                                       break;
-                               }
+               probenum = -1;
+               for (l = sdi->probes; l; l = l->next) {
+                       probe = (struct sr_probe *)l->data;
+                       if (probe->enabled
+                               && !strncmp(probe->name, tokens[i],
+                                       strlen(probe->name))) {
+                               probenum = probe->index;
+                               break;
                        }
-               } else {
-                       probenum = strtol(tokens[i], NULL, 10);
                }
 
                if (probenum < 0 || probenum >= max_probes) {
-                       sr_err("strutil: Invalid probe (%d).", probenum);
+                       sr_err("strutil: Invalid probe.");
                        error = TRUE;
                        break;
                }