From 7f99ebc6928c7e01aa067cbb8a811b161598e27f Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jun 2019 15:16:23 -0700 Subject: [PATCH 1/3] Also count terminating byte in fileneeded filename --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 4dcd3da4..989d20db 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -130,7 +130,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) nameonly(strcpy(wadfilename, wadfiles[i]->filename)); - if (p + 1 + 4 + strlen(wadfilename) + 16 > p_start + MAXFILENEEDED) + if (p + 1 + 4 + strlen(wadfilename) + 1 + 16 > p_start + MAXFILENEEDED) { // Too many files to send all at once if (netbuffer->packettype == PT_MOREFILESNEEDED) From d5e1c1af425dec36676da9f7009c0d8e41048268 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jun 2019 15:24:50 -0700 Subject: [PATCH 2/3] Add a comment by Sryder's request --- src/d_netfil.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_netfil.c b/src/d_netfil.c index 989d20db..a321fb78 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -130,6 +130,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) nameonly(strcpy(wadfilename, wadfiles[i]->filename)); + // Look below at the WRITE macros to understand what these numbers mean. if (p + 1 + 4 + strlen(wadfilename) + 1 + 16 > p_start + MAXFILENEEDED) { // Too many files to send all at once From bbee4a2554d62880747cfc343e4a6947719b010d Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Jun 2019 15:29:55 -0700 Subject: [PATCH 3/3] Cover edge case of WRITESTRINGN --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index a321fb78..76b66836 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -131,7 +131,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) nameonly(strcpy(wadfilename, wadfiles[i]->filename)); // Look below at the WRITE macros to understand what these numbers mean. - if (p + 1 + 4 + strlen(wadfilename) + 1 + 16 > p_start + MAXFILENEEDED) + if (p + 1 + 4 + min(strlen(wadfilename) + 1, MAX_WADPATH) + 16 > p_start + MAXFILENEEDED) { // Too many files to send all at once if (netbuffer->packettype == PT_MOREFILESNEEDED)