CLEANUP: lua: fix aliasing issues in the address matching code

Just use read_u32() instead of casting IPv6 addresses to uint32_t*.
This commit is contained in:
Willy Tarreau 2020-02-25 10:02:51 +01:00
parent 296cfd17ef
commit 26474c486d

View File

@ -18,6 +18,7 @@
#include <lua.h>
#include <lualib.h>
#include <common/net_helper.h>
#include <common/time.h>
#include <common/uri_auth.h>
@ -1520,10 +1521,10 @@ int hlua_match_addr(lua_State *L)
int i;
for (i = 0; i < 16; i += 4) {
if ((*(uint32_t *)&addr1->addr.v6.ip.s6_addr[i] &
*(uint32_t *)&addr2->addr.v6.mask.s6_addr[i]) !=
(*(uint32_t *)&addr2->addr.v6.ip.s6_addr[i] &
*(uint32_t *)&addr1->addr.v6.mask.s6_addr[i]))
if ((read_u32(&addr1->addr.v6.ip.s6_addr[i]) &
read_u32(&addr2->addr.v6.mask.s6_addr[i])) !=
(read_u32(&addr2->addr.v6.ip.s6_addr[i]) &
read_u32(&addr1->addr.v6.mask.s6_addr[i])))
break;
}
if (i == 16) {