From da4db7c65e9d9ac03acc3dc90310517c941d71d0 Mon Sep 17 00:00:00 2001 From: anthony-crystalpeak <108027248+anthony-crystalpeak@users.noreply.github.com> Date: Thu, 13 Jul 2023 12:44:48 -0700 Subject: [PATCH] BUG: Prevent npdu_len from wrapping around at npdu_len=1 (#452) --- apps/router-mstp/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/router-mstp/main.c b/apps/router-mstp/main.c index 592778ae..06cbc45f 100644 --- a/apps/router-mstp/main.c +++ b/apps/router-mstp/main.c @@ -662,7 +662,8 @@ static void network_control_handler(uint16_t snet, case NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK: /* add its DNETs to our routing table */ fprintf(stderr, "for Networks: "); - while (npdu_len) { + len = 2; + while (npdu_len >= len) { len = decode_unsigned16(&npdu[npdu_offset], &dnet); fprintf(stderr, "%hu", dnet); dnet_add(snet, dnet, src);