From 937aa91e5dc97c30276509490252192c82fd9380 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 23 Feb 2026 18:44:27 +0300 Subject: [PATCH] nfqws2: prevent OOB read in addpool --- nfq2/hostlist.c | 21 ++++++++------- nfq2/ipset.c | 71 +++++++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/nfq2/hostlist.c b/nfq2/hostlist.c index cda73a9..75701a2 100644 --- a/nfq2/hostlist.c +++ b/nfq2/hostlist.c @@ -11,7 +11,7 @@ static bool addpool(hostlist_pool **hostlist, char **s, const char *end, int *ct for (; p=sizeof(cidr)) l=sizeof(cidr)-1; - memcpy(cidr,*s,l); - cidr[l]=0; + // comment line + if (!(*p == '#' || *p == ';' || *p == '/' || *p == '\r' || *p == '\n' )) + { + *s=p; + // advance to the token's end + for (; pips4, &c4)) + l = p-*s; + if (l>=sizeof(cidr)) l=sizeof(cidr)-1; + memcpy(cidr,*s,l); + cidr[l]=0; + + if (parse_cidr4(cidr,&c4)) { - ipsetDestroy(ips); - return false; + if (!ipset4AddCidr(&ips->ips4, &c4)) + { + ipsetDestroy(ips); + return false; + } + if (ct) (*ct)++; } - if (ct) (*ct)++; - } - else if (parse_cidr6(cidr,&c6)) - { - if (!ipset6AddCidr(&ips->ips6, &c6)) + else if (parse_cidr6(cidr,&c6)) { - ipsetDestroy(ips); - return false; + if (!ipset6AddCidr(&ips->ips6, &c6)) + { + ipsetDestroy(ips); + return false; + } + if (ct) (*ct)++; } - if (ct) (*ct)++; + else + DLOG_ERR("bad ip or subnet : %s\n",cidr); } - else - DLOG_ERR("bad ip or subnet : %s\n",cidr); } // skip remaining non-eol chars @@ -83,18 +87,21 @@ static bool AppendIpset(ipset *ips, const char *filename) { DLOG_CONDUP("zlib compression detected. uncompressed size : %zu\n", zsize); - p = zbuf; - e = zbuf + zsize; - while(p