From 566d6dc4b7c0cb1498eded7a1c8fcd2fe18153b3 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 28 Sep 2020 17:46:12 +0200 Subject: [PATCH] boundry check for tosend buffer --- armsrc/BigBuf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c index f6c111d85..733f8c7f9 100644 --- a/armsrc/BigBuf.c +++ b/armsrc/BigBuf.c @@ -292,6 +292,12 @@ void tosend_reset(void) { } void tosend_stuffbit(int b) { + + if (toSend.max >= TOSEND_BUFFER_SIZE - 1) { + Dbprintf(_RED_("toSend overflow")); + return; + } + if (toSend.bit >= 8) { toSend.max++; toSend.buf[toSend.max] = 0; @@ -299,7 +305,7 @@ void tosend_stuffbit(int b) { } if (b) - toSend.buf[ toSend.max] |= (1 << (7 - toSend.bit)); + toSend.buf[toSend.max] |= (1 << (7 - toSend.bit)); toSend.bit++;