Attention is currently required from: daniel, fixeria, lynxis, ws1004. pespin has posted comments on this change by ws1004. ( https://gerrit.osmocom.org/c/libosmocore/+/44138?usp=email ) Change subject: gb: ns2: clamp embedded NS PDU to msgb tailroom ...................................................................... Patch Set 2: (2 comments) File src/gb/gprs_ns2.c: https://gerrit.osmocom.org/c/libosmocore/+/44138/comment/86597d43_0ca5b124?u... : PS2, Line 755: /* The original PDU can be larger than what is left in our own This all looks a bit too much convoluted imho. What about the following which doesn't need so much unsigned vs signed checks? const unsigned int avail = (int)msgb_tailroom(msg); unsigned int embed_len = msgb_l2len(orig_msg); if (avail < 3) embed_len = 0; else if (avail < 3 + embed_len) embed_len = avail - 3; if (embed_len > 0) msgb_tvlv_put(msg, NS_IE_PDU, embed_len, orig_msg->l2h); File src/gb/gprs_ns2_message.c: https://gerrit.osmocom.org/c/libosmocore/+/44138/comment/00f93736_78c4bc05?u... : PS2, Line 469: else if (nsvc->bind->mtu - msgb_length(msg) < max_orig_len) Again, this looks imho too convoluted. I propose this: /* Trim available space to MTU: */ unsigned int avail = msgb_tailroom(msg); if (msgb_length(msg) > nsvc->bind->mtu) avail = 0; else if (nsvc->bind->mtu - msgb_length(msg) > avail) avail = nsvc->bind->mtu - msgb_length(msg); /* Figure out how many origin PDU bytes we can fit given available space: */ if (avail < 3) orig_len = 0; else orig_len = avail - 3; if (orig_len > 0) msgb_tvlv_put(msg, NS_IE_PDU, orig_len, orig_msg->l2h); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/44138?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iac1c5c15875f30f34d0f7e9fc74264530a02b6ae Gerrit-Change-Number: 44138 Gerrit-PatchSet: 2 Gerrit-Owner: ws1004 <ws1004@kakao.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <daniel@totalueberwachung.de> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: lynxis <lynxis@fe80.eu> Gerrit-Reviewer: pespin <pespin@sysmocom.de> Gerrit-Attention: lynxis <lynxis@fe80.eu> Gerrit-Attention: daniel <daniel@totalueberwachung.de> Gerrit-Attention: fixeria <vyanitskiy@sysmocom.de> Gerrit-Attention: ws1004 <ws1004@kakao.com> Gerrit-Comment-Date: Thu, 19 Nov 2026 10:17:29 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No