Change in osmo-bts[master]: common/paging.c: fix unaligned pointer access
Vadim Yanitskiy
gerrit-no-reply at lists.osmocom.org
Wed Apr 24 07:55:54 UTC 2019
Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13769
Change subject: common/paging.c: fix unaligned pointer access
......................................................................
common/paging.c: fix unaligned pointer access
Passing a pointer to a packed structure to tmsi_mi_to_uint() may
result in unaligned pointer value. Found with clang-8.
Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777
---
M src/common/paging.c
1 file changed, 22 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/69/13769/1
diff --git a/src/common/paging.c b/src/common/paging.c
index aa604e7..d5e99bf 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -302,7 +302,9 @@
uint8_t cneed2, const uint8_t *identity3_lv)
{
struct gsm48_paging2 *pt2 = (struct gsm48_paging2 *) out_buf;
+ uint32_t tmsi1, tmsi2;
uint8_t *cur;
+ int rc;
memset(out_buf, 0, sizeof(*pt2));
@@ -311,8 +313,12 @@
pt2->pag_mode = GSM48_PM_NORMAL;
pt2->cneed1 = cneed1;
pt2->cneed2 = cneed2;
- tmsi_mi_to_uint(&pt2->tmsi1, tmsi1_lv);
- tmsi_mi_to_uint(&pt2->tmsi2, tmsi2_lv);
+ rc = tmsi_mi_to_uint(&tmsi1, tmsi1_lv);
+ if (rc == 0)
+ pt2->tmsi1 = tmsi1;
+ rc = tmsi_mi_to_uint(&tmsi2, tmsi2_lv);
+ if (rc == 0)
+ pt2->tmsi2 = tmsi2;
cur = out_buf + sizeof(*pt2);
if (identity3_lv)
@@ -329,6 +335,8 @@
const uint8_t *tmsi4_lv, uint8_t cneed4)
{
struct gsm48_paging3 *pt3 = (struct gsm48_paging3 *) out_buf;
+ uint32_t tmsi1, tmsi2, tmsi3, tmsi4;
+ int rc;
memset(out_buf, 0, sizeof(*pt3));
@@ -337,10 +345,18 @@
pt3->pag_mode = GSM48_PM_NORMAL;
pt3->cneed1 = cneed1;
pt3->cneed2 = cneed2;
- tmsi_mi_to_uint(&pt3->tmsi1, tmsi1_lv);
- tmsi_mi_to_uint(&pt3->tmsi2, tmsi2_lv);
- tmsi_mi_to_uint(&pt3->tmsi3, tmsi3_lv);
- tmsi_mi_to_uint(&pt3->tmsi4, tmsi4_lv);
+ rc = tmsi_mi_to_uint(&tmsi1, tmsi1_lv);
+ if (rc == 0)
+ pt3->tmsi1 = tmsi1;
+ rc = tmsi_mi_to_uint(&tmsi2, tmsi2_lv);
+ if (rc == 0)
+ pt3->tmsi2 = tmsi2;
+ rc = tmsi_mi_to_uint(&tmsi3, tmsi3_lv);
+ if (rc == 0)
+ pt3->tmsi3 = tmsi3;
+ rc = tmsi_mi_to_uint(&tmsi4, tmsi4_lv);
+ if (rc == 0)
+ pt3->tmsi4 = tmsi4;
/* The structure definition in libosmocore is wrong. It includes as last
* byte some invalid definition of chneed3/chneed4, so we must do this by hand
--
To view, visit https://gerrit.osmocom.org/13769
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777
Gerrit-Change-Number: 13769
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190424/7e76ba6a/attachment.html>
More information about the gerrit-log
mailing list