This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has submitted this change and it was merged.
Change subject: ranap_msg_factory: sanitize: memcpy instead of unaligned int copy
......................................................................
ranap_msg_factory: sanitize: memcpy instead of unaligned int copy
The sanitize build complains about writing to a uint32_t that is not 4-byte
aligned. Instead, write the uint32_t by memcpy.
For that, move the common ntohl() to the top and store in a local uint32_t,
memcpy() from that in both code paths.
Change-Id: Iacdd15421f824dd009448a96355b533dff28258b
---
M src/ranap_msg_factory.c
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
Holger Freyther: Looks good to me, approved
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index ef3e9ef..fe7e325 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -638,6 +638,7 @@
{
uint8_t *buf;
unsigned int len;
+ uint32_t ip_h = ntohl(ip);
if (use_x213_nsap) {
len = 160/8;
@@ -645,11 +646,11 @@
buf[0] = 0x35; /* AFI For IANA ICP */
buf[1] = 0x00; /* See A.5.2.1.2.7 of X.213 */
buf[2] = 0x01;
- *(uint32_t *)&buf[3] = ntohl(ip);
+ memcpy(&buf[3], &ip_h, sizeof(ip_h));
} else {
- len = 4;
+ len = sizeof(ip_h);
buf = CALLOC(len, sizeof(uint8_t));
- *(uint32_t *)buf = ntohl(ip);
+ memcpy(buf, &ip_h, sizeof(ip_h));
}
out->buf = buf;
out->size = len;
--
To view, visit https://gerrit.osmocom.org/4928
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iacdd15421f824dd009448a96355b533dff28258b
Gerrit-PatchSet: 3
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>