From: Felix Fietkau Date: Tue, 23 Aug 2022 20:35:54 +0000 (+0200) Subject: pex: fix null pointer check X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=547be90c5a6cc229e3e5b4fa8221b1a6ab9638e7;p=project%2Funetd.git pex: fix null pointer check check for local_host null pointer before dereferencing it Signed-off-by: Felix Fietkau --- diff --git a/pex.c b/pex.c index 38d314d..0e66d24 100644 --- a/pex.c +++ b/pex.c @@ -462,15 +462,17 @@ network_pex_fd_cb(struct uloop_fd *fd, unsigned int events) int network_pex_open(struct network *net) { - struct network_peer *local = &net->net_config.local_host->peer; + struct network_host *local_host = net->net_config.local_host; + struct network_peer *local; struct network_pex *pex = &net->pex; struct sockaddr_in6 sin6 = {}; int yes = 1; int fd; - if (!local || !net->net_config.pex_port) + if (!local_host || !net->net_config.pex_port) return 0; + local = &local_host->peer; fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (fd < 0) return -1;