From 9893d6e61c445a1bd6b0e6bc36a331ae9f1c82e2 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 22 Jul 2026 18:08:14 +0000 Subject: [PATCH] increase line buffer, add truncation error. Fixes #3201. Closes #3367 --- CHANGELOG | 3 +++ service_scan.cc | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2755059a6..782f4587b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #Nmap Changelog ($Id$); -*-text-*- +o [GH#3201][GH#3367] Increase line length limit for nmap-service-probes and + correctly handle lines that are too long. [@liquidpele, Ashutosh Kumar Singh] + o [GH#3414] Avoid out-of-bounds read when parsing PTR domain names. [@toor11 (Juri)] o Fixed an issue with parsing nmap-service-probes that could cause a corrupted diff --git a/service_scan.cc b/service_scan.cc index c5df713d9..cedf5498c 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -1319,7 +1319,7 @@ void ServiceProbe::addMatch(const char *match, int lineno) { (servicematch) which use this */ void parse_nmap_service_probe_file(AllProbes *AP, const char *filename) { ServiceProbe *newProbe = NULL; - char line[2048]; + char line[8192]; int lineno = 0; FILE *fp; @@ -1330,6 +1330,9 @@ void parse_nmap_service_probe_file(AllProbes *AP, const char *filename) { while(fgets(line, sizeof(line), fp)) { lineno++; + size_t linelen = strnlen(line, sizeof(line)); + if (linelen == sizeof(line) - 1 && line[linelen - 1] != '\n' && !feof(fp)) + fatal("Line %d of %s is too long (limit is %d characters)", lineno, filename, (int)(sizeof(line) - 1)); if (*line == '\n' || *line == '#') continue;