From 1639237e71f2f2bf510a4633b94d21b247f4cd3d Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Sat, 1 Apr 2023 15:23:26 -1000 Subject: [PATCH] VCT: Validate the srcVC before indexing the virtualCircuitList --- Firmware/Tools/VcServerTest.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Firmware/Tools/VcServerTest.c b/Firmware/Tools/VcServerTest.c index b0c62a30..4c93f5df 100644 --- a/Firmware/Tools/VcServerTest.c +++ b/Firmware/Tools/VcServerTest.c @@ -686,8 +686,27 @@ void radioCommandComplete(VC_SERIAL_MESSAGE_HEADER * header, uint8_t * data, uin //The command processor is still running commandProcessorRunning = STALL_CHECK_COUNT; - //Done with this command + //Validate the srcVc srcVc = header->radio.srcVc; + if (srcVc >= PC_REMOTE_COMMAND) + { + if (srcVc < (uint8_t)VC_RSVD_SPECIAL_VCS) + srcVc &= VCAB_NUMBER_MASK; + else + switch(srcVc) + { + default: + fprintf(stderr, "ERROR: Unknown VC: %d (0x%02x)\n", srcVc, srcVc); + exit(-2); + break; + + //Ignore this command + case (uint8_t)VC_UNASSIGNED: + return; + } + } + + //Done with this command if (srcVc == myVc) { if (pcActiveCommand < CMD_LIST_SIZE)