mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Simplify sscanf pattern for parsing /etc/hosts
This commit is contained in:
@@ -1005,9 +1005,8 @@ static void parse_etchosts(const char *fname) {
|
|||||||
// Skip any leading whitespace
|
// Skip any leading whitespace
|
||||||
while (*tp == ' ' || *tp == '\t') tp++;
|
while (*tp == ' ' || *tp == '\t') tp++;
|
||||||
|
|
||||||
std::stringstream pattern;
|
static const char *pattern = "%" STR(INET6_ADDRSTRLEN) "s %255s";
|
||||||
pattern << "%" << INET6_ADDRSTRLEN << "s %255s";
|
if (sscanf(tp, pattern, ipaddrstr, hname) == 2)
|
||||||
if (sscanf(tp, pattern.str().c_str(), ipaddrstr, hname) == 2)
|
|
||||||
if (sockaddr_storage_inet_pton(ipaddrstr, &ia))
|
if (sockaddr_storage_inet_pton(ipaddrstr, &ia))
|
||||||
{
|
{
|
||||||
const std::string hname_ = hname;
|
const std::string hname_ = hname;
|
||||||
|
|||||||
Reference in New Issue
Block a user