mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Don't bail on PCRE2 match errors. Better debug info.
This commit is contained in:
@@ -535,17 +535,20 @@ const struct MatchDetails *ServiceProbeMatch::testMatch(const u8 *buf, int bufle
|
|||||||
|
|
||||||
rc = pcre2_match(regex_compiled, (PCRE2_SPTR8)bufc, buflen, 0, 0, match_data, match_context);
|
rc = pcre2_match(regex_compiled, (PCRE2_SPTR8)bufc, buflen, 0, 0, match_data, match_context);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (rc == PCRE2_ERROR_MATCHLIMIT) {
|
// Probably just didn't match. However, PCRE2 errors may happen with bad
|
||||||
if (o.debugging || o.verbose > 1)
|
// patterns. We want to know, but don't abandon the whole scan.
|
||||||
error("Warning: Hit PCRE_ERROR_MATCHLIMIT when probing for service %s with the regex '%s'", servicename, matchstr);
|
if (rc != PCRE2_ERROR_NOMATCH) {
|
||||||
} else
|
if (o.verbose || o.debugging) {
|
||||||
if (rc == PCRE2_ERROR_RECURSIONLIMIT) {
|
error("Warning: PCRE2 error %d when probing for service %s with the regex '%s'", rc, servicename, matchstr);
|
||||||
if (o.debugging || o.verbose > 1)
|
|
||||||
error("Warning: Hit PCRE_ERROR_RECURSIONLIMIT when probing for service %s with the regex '%s'", servicename, matchstr);
|
|
||||||
} else
|
|
||||||
if (rc != PCRE2_ERROR_NOMATCH) {
|
|
||||||
fatal("Unexpected PCRE error (%d) when probing for service %s with the regex '%s'", rc, servicename, matchstr);
|
|
||||||
}
|
}
|
||||||
|
if (o.debugging) {
|
||||||
|
pcre2_get_error_message(rc, (unsigned char *)info, SERVICE_EXTRA_LEN);
|
||||||
|
error("PCRE2 error message: %s", info);
|
||||||
|
if (o.debugging > 1) {
|
||||||
|
error("Service data: \n%s", hexdump(buf, buflen));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Yeah! Match apparently succeeded.
|
// Yeah! Match apparently succeeded.
|
||||||
// Now lets get the version number if available
|
// Now lets get the version number if available
|
||||||
|
|||||||
Reference in New Issue
Block a user