Skip to content

Commit

Permalink
Merge pull request #1018 from pi-hole/fix/iface_name_in_TCP_worker
Browse files Browse the repository at this point in the history
Check for validity if iface pointe before dereferencing it
  • Loading branch information
DL6ER authored Jan 15, 2021
2 parents 6b9a116 + 0a9742a commit a87d59b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/dnsmasq/dnsmasq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ static void check_dns_listeners(time_t now)
fcntl(confd, F_SETFL, flags & ~O_NONBLOCK);

/******* Pi-hole modification *******/
FTL_TCP_worker_created(confd, iface->name);
FTL_TCP_worker_created(confd, iface != NULL ? iface->name : NULL);
/************************************/

buff = tcp_request(confd, now, &tcp_addr, netmask, auth_dns);
Expand Down
5 changes: 4 additions & 1 deletion src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2108,8 +2108,11 @@ void FTL_TCP_worker_created(const int confd, const char *iface_name)
inet_ntop(iface_sockaddr.sa.sa_family, &iface_addr, local_ip, ADDRSTRLEN);
}

// Substitute interface name if not available
if(iface_name == NULL)
iface_name = "N/A (iface is NULL)";
// Print log
logg("TCP worker forked for client %s on interface %s (%s)", peer_ip, iface_name, local_ip);
logg("TCP worker forked for client %s on interface %s with IP %s", peer_ip, iface_name, local_ip);
}

if(main_pid() == getpid())
Expand Down

0 comments on commit a87d59b

Please sign in to comment.