Skip to content

Commit

Permalink
Resolves crash opportunities caused by unexpected libpcap version str…
Browse files Browse the repository at this point in the history
…ing format. Fixes #1112
  • Loading branch information
nnposter committed Feb 1, 2018
1 parent ff62300 commit 6889a2f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,5 +1,8 @@
#Nmap Changelog ($Id$); -*-text-*-

o [GH#1112] Resolved crash opportunities caused by unexpected libpcap version
string format. [Gisle Vanem, nnposter]

o [NSE][GH#1083] New set of Telnet softmatches for version detection based on
Telnet DO/DON'T options offered, covering a wide variety of devices and
operating systems. [D Roberson]
Expand Down
9 changes: 4 additions & 5 deletions nmap.cc
Expand Up @@ -2749,11 +2749,10 @@ static void display_nmap_version() {

const char *pcap_version = pcap_lib_version();
#ifdef WIN32
const char *pcap_num = strstr(pcap_version, "version ");
if (pcap_num) {
pcap_num += strlen("version ");
}
std::string pcap_num_str (pcap_num, strchr(pcap_num, ',') - pcap_num);
const char *pcap_num = strpbrk(pcap_version, "0123456789");
if (pcap_num == NULL)
pcap_num = "(unknown)";
std::string pcap_num_str (pcap_num, strcspn(pcap_num, ","));
#else
std::string pcap_num_str = get_word_or_quote(pcap_version, 2);
#endif
Expand Down

0 comments on commit 6889a2f

Please sign in to comment.