From 6b2070c6e977716c1a13eba52e8c9bed43cf8843 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 22 Oct 2020 23:19:59 +0200 Subject: [PATCH] fix 18a6ab0201536bd67f09ac0646a7c99369e9910c --- miniupnpd/upnppermissions.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miniupnpd/upnppermissions.c b/miniupnpd/upnppermissions.c index 38acc2d..75a7adf 100644 --- a/miniupnpd/upnppermissions.c +++ b/miniupnpd/upnppermissions.c @@ -283,19 +283,22 @@ get_permitted_ext_ports(uint32_t * allowed, { if ((j % 32) == 0 && ((int)permary[i].eport_max >= (j + 31))) { + /* 32bits at once */ allowed[j / 32] = (permary[i].type == UPNPPERM_ALLOW) ? 0xffffffff : 0; j += 32; } else { - while ((j % 32) != 0 && (j <= (int)permary[i].eport_max)) + do { + /* one bit at once */ if (permary[i].type == UPNPPERM_ALLOW) allowed[j / 32] |= (1 << (j % 32)); else allowed[j / 32] &= ~(1 << (j % 32)); j++; } + while ((j % 32) != 0 && (j <= (int)permary[i].eport_max)); } } }