mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Handle blank lines and duplicate protocol numbers. Fixes #2558
This commit is contained in:
parent
ee059c44fe
commit
87274f81fc
1 changed files with 9 additions and 3 deletions
12
protocols.cc
12
protocols.cc
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue