From 547be90c5a6cc229e3e5b4fa8221b1a6ab9638e7 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 23 Aug 2022 22:35:54 +0200 Subject: [PATCH] pex: fix null pointer check check for local_host null pointer before dereferencing it Signed-off-by: Felix Fietkau --- pex.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.30.2