increase line buffer, add truncation error. Fixes #3201. Closes #3367

This commit is contained in:
dmiller 2026-07-22 18:08:14 +00:00
parent 206d06abfd
commit 9893d6e61c
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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;