From 3406ff488ce20b04d6b0e9bcead06c6492f67922 Mon Sep 17 00:00:00 2001 From: Jorge Pereira Date: Tue, 14 Mar 2023 15:44:21 -0300 Subject: [PATCH] Fix runtime error: load of misaligned address in xlat_integer() Such error: src/main/xlat.c:206:38: runtime error: load of misaligned address 0x00010410ba72 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment 0x00010410ba72: note: pointer points here 00 00 00 20 39 38 37 3e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/main/xlat.c:206:38 in --- src/main/xlat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/xlat.c b/src/main/xlat.c index 8000aa1525..4bd0a379cb 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -203,7 +203,7 @@ static ssize_t xlat_integer(UNUSED void *instance, REQUEST *request, return snprintf(out, outlen, "%u", htonl(vp->vp_ipaddr)); case PW_TYPE_IPV4_PREFIX: - return snprintf(out, outlen, "%u", htonl((*(uint32_t *)(vp->vp_ipv4prefix + 2)))); + return snprintf(out, outlen, "%u", htonl((*(uint32_t *)(&vp->vp_ipv4prefix[2])))); case PW_TYPE_INTEGER: return snprintf(out, outlen, "%u", vp->vp_integer); -- 2.47.3