1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Deal with missing 'R' test in fingerprints/observations

This commit is contained in:
dmiller
2023-05-15 17:31:38 +00:00
parent d29f59626a
commit 15a93e7b34

View File

@@ -643,6 +643,7 @@ bool FingerTest::str2AVal(const char *str, const char *end) {
assert(results); assert(results);
assert(def); assert(def);
const char *q = str, *p=str; const char *q = str, *p=str;
u8 maxIdx = 0;
if (!def->hasR && 0 == strncmp("R=N", str, end - str)) { if (!def->hasR && 0 == strncmp("R=N", str, end - str)) {
return true; return true;
} }
@@ -657,7 +658,8 @@ bool FingerTest::str2AVal(const char *str, const char *end) {
return false; return false;
} }
std::map<FPstr, u8>::const_iterator idx = def->AttrIdx.find(FPstr(p, q)); std::map<FPstr, u8>::const_iterator idx = def->AttrIdx.find(FPstr(p, q));
if (idx == def->AttrIdx.end() || AVs[idx->second] != NULL) { u8 j = idx->second;
if (idx == def->AttrIdx.end() || AVs[j] != NULL) {
error("Parse error with AVal string (%s) in nmap-os-db file", str); error("Parse error with AVal string (%s) in nmap-os-db file", str);
return false; return false;
} }
@@ -666,13 +668,24 @@ bool FingerTest::str2AVal(const char *str, const char *end) {
if (!q) { if (!q) {
q = end; q = end;
} }
AVs[idx->second] = string_pool_substr(p, q); AVs[j] = string_pool_substr(p, q);
maxIdx = MAX(maxIdx, j);
p = q + 1; p = q + 1;
} }
if (p < end) { if (p < end) {
error("Too many values in AVal string (%s)", str); error("Too many values in AVal string (%s)", str);
return false; return false;
} }
if (def->hasR) {
if (maxIdx > 0) {
assert(AVs[0] == NULL || 0 == strcmp("Y", AVs[0]));
AVs[0] = "Y";
}
else {
assert(AVs[0] == NULL || 0 == strcmp("N", AVs[0]));
AVs[0] = "N";
}
}
return true; return true;
} }