laforge submitted this change.

View Change

Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve
bankd: fix hh_ext pointer arithmetic in worker_transceive_loop()

The pointer to the IPA extension header was calculated as follows:

hh_ext = (struct ipaccess_head_ext *) buf + sizeof(*hh);

Due to the operator precedence, 'buf' is casted first, so the offset
is scaled by sizeof(struct ipaccess_head_ext) rather than being added
in bytes. This happens to work only because that struct is 1 byte
in size. Point hh_ext to the data following the IPA header instead.

No functional change.

Change-Id: Ib3675125b4e30cb2d59c799e68167753bef2358c
---
M src/bankd/bankd_main.c
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c
index d04b468..70aa9f9 100644
--- a/src/bankd/bankd_main.c
+++ b/src/bankd/bankd_main.c
@@ -1028,7 +1028,7 @@
return 0;
}

- hh_ext = (struct ipaccess_head_ext *) buf + sizeof(*hh);
+ hh_ext = (struct ipaccess_head_ext *) hh->data;
if (data_len < sizeof(*hh_ext)) {
LOGW(worker, "Received short message\n");
return -5;

To view, visit change 44183. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-Change-Id: Ib3675125b4e30cb2d59c799e68167753bef2358c
Gerrit-Change-Number: 44183
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>