1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-31 20:09:02 +00:00

Handle blank lines and duplicate protocol numbers. Fixes #2558

This commit is contained in:
dmiller
2022-11-04 22:07:28 +00:00
parent ee059c44fe
commit 87274f81fc

View File

@@ -117,7 +117,7 @@ static int nmap_protocols_init() {
p = line;
while(*p && isspace((int) (unsigned char) *p))
p++;
if (*p == '#')
if (*p == '#' || *p == '\0')
continue;
res = sscanf(line, "%127s %hu", protocolname, &protno);
if (res !=2 || protno > UCHAR_MAX) {
@@ -134,12 +134,18 @@ static int nmap_protocols_init() {
/* Now we make sure our protocols don't have duplicates */
if (!status.second) {
if (o.debugging > 1) {
error("Protocol %d is duplicated in protocols file %s", protno, filename);
error("Protocol %d (%s) has duplicate number (%d) in protocols file %s", status.first->second.p_proto, ent.p_name, protno, filename);
}
continue;
}
if (protocol_table[protno]) {
if (o.debugging > 1) {
error("Protocol %d (%s) has duplicate name (%s) in protocols file %s", protno, protocol_table[protno]->p_name, ent.p_name, filename);
}
continue;
}
assert(!protocol_table[protno]);
protocol_table[protno] = &status.first->second;
}
fclose(fp);