mirror of
https://github.com/nmap/nmap.git
synced 2026-02-12 08:26:33 +00:00
Use FQDN_LEN instead of MAXHOSTNAMELEN for DNS name buffers
This closes #140 (issue #140), namely "Use correct lengths for FQDN, not MAXHOSTNAMELEN"
This commit is contained in:
@@ -134,6 +134,7 @@
|
||||
#include "nbase.h"
|
||||
#include "NmapOps.h"
|
||||
#include "utils.h"
|
||||
#include "nmap.h"
|
||||
#include "nmap_error.h"
|
||||
|
||||
extern NmapOps o;
|
||||
@@ -429,8 +430,10 @@ const char *Target::NameIP(char *buf, size_t buflen) const {
|
||||
|
||||
/* This next version returns a static buffer -- so no concurrency */
|
||||
const char *Target::NameIP() const {
|
||||
if (!nameIPBuf) nameIPBuf = (char *) safe_malloc(MAXHOSTNAMELEN + INET6_ADDRSTRLEN);
|
||||
return NameIP(nameIPBuf, MAXHOSTNAMELEN + INET6_ADDRSTRLEN);
|
||||
/* Add 3 characters for the hostname and IP string, hence we allocate
|
||||
(FQDN_LEN + INET6_ADDRSTRLEN + 4) octets, with octet for the null terminator */
|
||||
if (!nameIPBuf) nameIPBuf = (char *) safe_malloc(FQDN_LEN + INET6_ADDRSTRLEN + 4);
|
||||
return NameIP(nameIPBuf, FQDN_LEN + INET6_ADDRSTRLEN + 4);
|
||||
}
|
||||
|
||||
/* Returns the next hop for sending packets to this host. Returns true if
|
||||
|
||||
Reference in New Issue
Block a user