From 8d699864b1b6bd52704811574944013ae46f71f7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 11 Aug 2023 18:14:28 -0700 Subject: [PATCH] DebugPrintpacket: fix underflow for PT_TEXTCMD reporting --- src/d_net.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/d_net.c b/src/d_net.c index 27b1ef2f4..50f9d2d2a 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -897,9 +897,12 @@ static void DebugPrintpacket(const char *header) size = READUINT16(p); } - fprintf(debugfile, " length %d\n", size); + // First two bytes: reported total size of payload (does not include the first two bytes) + // Next byte (effectively 3rd byte): id for the netcmd + // Variable length: payload of netcmd, then more netcmds (id, payload) in sequence + fprintf(debugfile, " length %d, actual length %d\n", size, doomcom->datalength); fprintf(debugfile, "[%s]", netxcmdnames[netbuffer->u.textcmd[2] - 1]); - fprintfstringnewline((char *)netbuffer->u.textcmd + 3, size - 2); + fprintfstringnewline((char *)netbuffer->u.textcmd, doomcom->datalength); break; } case PT_SERVERCFG: