Hello Max, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/4915 to look at the new patch set (#3). sanitize build: ensure uint16/32 alignment in gtpie_test and in46a_test Fixes sanitize build failures: Testing gtpie_tlv() ../../../../src/osmo-ggsn/tests/gtp/gtpie_test.c:30:2: runtime error: load of misaligned address 0x55c0a0830f21 for type 'uint16_t', which requires 2 byte alignment 0x55c0a0830f21: note: pointer points here 00 00 00 17 00 06 01 02 03 04 05 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ Testing gtpie_tv0() Testing gtpie_tv1() Testing gtpie_tv2() ../../../../src/osmo-ggsn/tests/gtp/gtpie_test.c:76:2: runtime error: load of misaligned address 0x55c0a0830f21 for type 'uint16_t', which requires 2 byte alignment 0x55c0a0830f21: note: pointer points here 00 00 00 2a ab cd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ Testing gtpie_tv4() ../../../../src/osmo-ggsn/tests/gtp/gtpie_test.c:90:2: runtime error: load of misaligned address 0x55c0a0830f21 for type 'uint32_t', which requires 4 byte alignment 0x55c0a0830f21: note: pointer points here 00 00 00 2a ab cd 01 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ Testing gtpie_tv8() ../../../../src/osmo-ggsn/tests/gtp/gtpie_test.c:104:2: runtime error: load of misaligned address 0x55c0a0830f21 for type 'uint32_t', which requires 4 byte alignment 0x55c0a0830f21: note: pointer points here 00 00 00 2a 00 01 02 03 04 05 06 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ ../../../../src/osmo-ggsn/tests/gtp/gtpie_test.c:105:2: runtime error: load of misaligned address 0x55c0a0830f25 for type 'uint32_t', which requires 4 byte alignment 0x55c0a0830f25: note: pointer points here 00 01 02 03 04 05 06 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ Change-Id: I9eb16450af942d6464211e190f6a4d5a1d814842 --- M tests/gtp/gtpie_test.c M tests/lib/in46a_test.c 2 files changed, 11 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/15/4915/3 diff --git a/tests/gtp/gtpie_test.c b/tests/gtp/gtpie_test.c index 8d87dcc..513b4ff 100644 --- a/tests/gtp/gtpie_test.c +++ b/tests/gtp/gtpie_test.c @@ -7,6 +7,8 @@ #include <osmocom/core/utils.h> #include <osmocom/core/application.h> #include <osmocom/core/logging.h> +#include <osmocom/core/bit16gen.h> +#include <osmocom/core/bit32gen.h> #include "../../lib/syserr.h" #include "../../gtp/gtpie.h" @@ -27,7 +29,7 @@ OSMO_ASSERT(rc == 0); OSMO_ASSERT(len == sizeof(in) + 3); OSMO_ASSERT(buf[0] == 23); - OSMO_ASSERT(ntohs(*(uint16_t *) &buf[1]) == sizeof(in)); + OSMO_ASSERT(osmo_load16be(&buf[1]) == sizeof(in)); OSMO_ASSERT(!memcmp(buf+3, in, sizeof(in))); /* overflow */ @@ -73,7 +75,7 @@ OSMO_ASSERT(rc == 0); OSMO_ASSERT(len == 3); OSMO_ASSERT(buf[0] == 42); - OSMO_ASSERT(ntohs(*(uint16_t *) &buf[1]) == 0xABCD); + OSMO_ASSERT(osmo_load16be(&buf[1]) == 0xABCD); } static void test_gtpie_tv4() @@ -87,7 +89,7 @@ OSMO_ASSERT(rc == 0); OSMO_ASSERT(len == 5); OSMO_ASSERT(buf[0] == 42); - OSMO_ASSERT(ntohl(*(uint32_t *) &buf[1]) == 0xABCD0123); + OSMO_ASSERT(osmo_load32be(&buf[1]) == 0xABCD0123); } static void test_gtpie_tv8() @@ -101,8 +103,8 @@ OSMO_ASSERT(rc == 0); OSMO_ASSERT(len == 9); OSMO_ASSERT(buf[0] == 42); - OSMO_ASSERT(ntohl(*(uint32_t *) &buf[1]) == 0x00010203); - OSMO_ASSERT(ntohl(*(uint32_t *) &buf[5]) == 0x04050607); + OSMO_ASSERT(osmo_load32be(&buf[1]) == 0x00010203); + OSMO_ASSERT(osmo_load32be(&buf[5]) == 0x04050607); } int main(int argc, char **argv) diff --git a/tests/lib/in46a_test.c b/tests/lib/in46a_test.c index ab7156f..bca1015 100644 --- a/tests/lib/in46a_test.c +++ b/tests/lib/in46a_test.c @@ -159,6 +159,7 @@ .v6.s6_addr = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }, }; struct ul66_t eua; + uint32_t v4_addr; printf("testing in46a_to_eua()\n"); @@ -171,7 +172,9 @@ OSMO_ASSERT(in46a_to_eua(&g_ia4, &eua) == 0); OSMO_ASSERT(eua.v[0] == PDP_EUA_ORG_IETF); OSMO_ASSERT(eua.v[1] == PDP_EUA_TYPE_v4); - OSMO_ASSERT(*(uint32_t *) &eua.v[2] == g_ia4.v4.s_addr); + /* uint32_t must be 4-byte aligned to not trigger sanitize build failure */ + memcpy(&v4_addr, &eua.v[2], sizeof(v4_addr)); + OSMO_ASSERT(v4_addr == g_ia4.v4.s_addr); /* IPv6 address */ OSMO_ASSERT(in46a_to_eua(&g_ia6, &eua) == 0); -- To view, visit https://gerrit.osmocom.org/4915 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I9eb16450af942d6464211e190f6a4d5a1d814842 Gerrit-PatchSet: 3 Gerrit-Project: osmo-ggsn Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de> Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max <msur...@sysmocom.de>