From 82177f5669b58c649971bf5c7a8e13ce8fb800f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 5 Jan 2018 13:45:54 +0100 Subject: [PATCH] Fix bug in RF Bridge when RF code contains the stop byte. Check overflow (#357) --- code/espurna/rfbridge.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/espurna/rfbridge.ino b/code/espurna/rfbridge.ino index dbd60e8a..2ff7721e 100644 --- a/code/espurna/rfbridge.ino +++ b/code/espurna/rfbridge.ino @@ -252,11 +252,14 @@ void _rfbReceive() { //DEBUG_MSG_P(PSTR("[RFBRIDGE] Received 0x%02X\n"), c); if (receiving) { - if (c == RF_CODE_STOP) { + if (c == RF_CODE_STOP && (_uartpos == 1 || _uartpos == 10)) { _rfbDecode(); receiving = false; - } else { + } else if (_uartpos < 10) { _uartbuf[_uartpos++] = c; + } else { + // wrong message, should have received a RF_CODE_STOP + receiving = false; } } else if (c == RF_CODE_START) { _uartpos = 0;