mirror of
https://github.com/nmap/nmap.git
synced 2025-12-30 11:29:01 +00:00
Remove the allocation and freeing of a fixed-size dynamic buffer and
replace it with a static buffer.
This commit is contained in:
19
nse_nsock.cc
19
nse_nsock.cc
@@ -813,14 +813,11 @@ void l_nsock_trace(nsock_iod nsiod, const char *message, int direction)
|
||||
int protocol;
|
||||
int af;
|
||||
|
||||
struct sockaddr_storage local;
|
||||
|
||||
struct sockaddr_storage remote;
|
||||
|
||||
if (!nsi_is_pcap(nsiod))
|
||||
{
|
||||
char *ipstring_local = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN);
|
||||
char *ipstring_remote = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN);
|
||||
if (!nsi_is_pcap(nsiod)) {
|
||||
char ipstring_local[INET6_ADDRSTRLEN];
|
||||
char ipstring_remote[INET6_ADDRSTRLEN];
|
||||
struct sockaddr_storage local;
|
||||
struct sockaddr_storage remote;
|
||||
|
||||
status = nsi_getlastcommunicationinfo(nsiod, &protocol, &af,
|
||||
(sockaddr *) &local, (sockaddr *) &remote, sizeof(sockaddr_storage));
|
||||
@@ -832,11 +829,7 @@ void l_nsock_trace(nsock_iod nsiod, const char *message, int direction)
|
||||
(direction == TO) ? ">" : "<",
|
||||
inet_ntop_both(af, &remote, ipstring_remote),
|
||||
inet_port_both(af, &remote), message);
|
||||
|
||||
free(ipstring_local);
|
||||
free(ipstring_remote);
|
||||
} else
|
||||
{ // is pcap device
|
||||
} else { // is pcap device
|
||||
log_write(LOG_STDOUT, "%s: %s | %s\n",
|
||||
SCRIPT_ENGINE, (direction == TO) ? ">" : "<", message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user