diff --git a/mongoose.c b/mongoose.c index d1aa09ca..98d43685 100644 --- a/mongoose.c +++ b/mongoose.c @@ -10246,6 +10246,7 @@ static struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, if (!c->is_udp && pkt->tcp && c->loc.port == pkt->tcp->dport && ((lsn && c->is_listening && !(c->loc.is_ip6 ^ (pkt->ip6 != NULL))) || (!lsn && !c->is_listening && c->rem.port == pkt->tcp->sport && + !(c->loc.is_ip6 ^ (pkt->ip6 != NULL)) && // IP or IPv6 to same dest ((!c->loc.is_ip6 && c->rem.addr.ip4 == pkt->ip->src) #if MG_ENABLE_IPV6 || (c->loc.is_ip6 && MG_IP6MATCH(c->rem.addr.ip6, pkt->ip6->src)) diff --git a/src/net_builtin.c b/src/net_builtin.c index ac072485..3cc379cb 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -602,6 +602,7 @@ static struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, if (!c->is_udp && pkt->tcp && c->loc.port == pkt->tcp->dport && ((lsn && c->is_listening && !(c->loc.is_ip6 ^ (pkt->ip6 != NULL))) || (!lsn && !c->is_listening && c->rem.port == pkt->tcp->sport && + !(c->loc.is_ip6 ^ (pkt->ip6 != NULL)) && // IP or IPv6 to same dest ((!c->loc.is_ip6 && c->rem.addr.ip4 == pkt->ip->src) #if MG_ENABLE_IPV6 || (c->loc.is_ip6 && MG_IP6MATCH(c->rem.addr.ip6, pkt->ip6->src))