From 17ff11240ee1ed8afd504b84a99990969a75544b Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Mon, 8 Oct 2012 23:56:06 +0200 Subject: [PATCH] don't accept numbers as probe identifiers in trigger string Only the probe name, as supplied by the device driver, is accepted. --- strutil.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/strutil.c b/strutil.c index 8abc556e..0ddeae09 100644 --- 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; }