From af05611914b5444235d5baf95f58d20145f56f27 Mon Sep 17 00:00:00 2001 From: CPunch Date: Wed, 26 Jan 2022 15:20:07 -0600 Subject: [PATCH] Sanity check that pktIDs from VAR_REQ packets are actually variadic - variadic packets *MUST* have a PKTSIZE of 0 in the provided pktSizeTable --- lib/src/lpeer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/lpeer.c b/lib/src/lpeer.c index ab8dab2..f56720a 100644 --- a/lib/src/lpeer.c +++ b/lib/src/lpeer.c @@ -49,8 +49,8 @@ bool laikaS_handlePeerIn(struct sLaika_peer *peer) { peer->pktID = laikaS_readByte(&peer->sock); - /* sanity check packet ID */ - if (peer->pktID >= LAIKAPKT_MAXNONE) + /* sanity check packet ID, (check valid range, check it's variadic) */ + if (peer->pktID >= LAIKAPKT_MAXNONE || peer->pktSizeTable[peer->pktID]) LAIKA_ERROR("received evil pktID!\n") /* try reading new packet size */