From 445c52cdf4fc359f9b5d544ce6d45ed476d656b1 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 2 Jun 2016 22:54:59 -0500 Subject: [PATCH] Add more validation to serial read state machine --- avr/send.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/avr/send.c b/avr/send.c index 611cade..3cd8f18 100644 --- a/avr/send.c +++ b/avr/send.c @@ -198,8 +198,24 @@ int main() { } case 2: { - header.type = c; - i++; + switch (c) { + case 0x01: + case 0x02: + case 0x04: + case 0x08: + case 0x0f: { + header.type = c; + i++; + + break; + } + + default: { + i = 0; + + break; + } + } break; }