]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
kdig: fix misaligned address load when printing EDE
authorDaniel Salzman <daniel.salzman@nic.cz>
Mon, 16 Aug 2021 11:20:09 +0000 (13:20 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Thu, 19 Aug 2021 17:45:11 +0000 (19:45 +0200)
src/utils/common/exec.c

index 07916145819f145c0a8ff48459b59b1327614d0e..220e3d1bd3381b45d99b0e7012ac04f6e611142b 100644 (file)
@@ -250,7 +250,9 @@ static void print_ede(const uint8_t *data, uint16_t len)
                printf("(malformed)");
                return;
        }
-       uint16_t errcode = be16toh(*(uint16_t *)data);
+       uint16_t errcode;
+       memcpy(&errcode, data, sizeof(errcode));
+       errcode = be16toh(errcode);
        const char *strerr = knot_edns_ede_strerr(errcode);
        if (len > 2) {
                printf("%hu (%s): '%.*s'", errcode, strerr, (int)(len - 2), data + 2);