From c2c80de8abfd08dec5c4086a438b5ce7c98aebab Mon Sep 17 00:00:00 2001 From: "adam@algroup.co.uk" Date: Wed, 2 Sep 2009 09:17:34 +0000 Subject: [PATCH] enforce askdemod argument 0 or 1 --- winsrc/command.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/winsrc/command.cpp b/winsrc/command.cpp index c1b3e372..f03bada4 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -2272,9 +2272,11 @@ static void Cmdaskdemod(char *str) { int c, high = 0, low = 0; // TODO: complain if we do not give 2 arguments here ! + // (AL - this doesn't make sense! we're only using one argument!!!) sscanf(str, "%i", &c); /* Detect high and lows and clock */ + // (AL - clock???) for (i = 0; i < GraphTraceLen; i++) { if (GraphBuffer[i] > high) @@ -2282,6 +2284,10 @@ static void Cmdaskdemod(char *str) { else if (GraphBuffer[i] < low) low = GraphBuffer[i]; } + if(c != 0 && c != 1) { + PrintToScrollback("Invalid argument: %s",str); + return; + } if (GraphBuffer[0] > 0) { GraphBuffer[0] = 1-c; @@ -2829,7 +2835,7 @@ static struct { char *docString; } CommandTable[] = { {"amp", CmdAmp, 1, "Amplify peaks"}, - {"askdemod", Cmdaskdemod, 1, " <0|1> -- Attempt to demodulate simple ASK tags"}, + {"askdemod", Cmdaskdemod, 1, "<0|1> -- Attempt to demodulate simple ASK tags"}, {"autocorr", CmdAutoCorr, 1, " -- Autocorrelation over window"}, {"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"}, {"bitstream", Cmdbitstream, 1, "[clock rate] -- Convert waveform into a bitstream"}, -- 2.39.2