dexter has uploaded this change for review.
msgb: dont return a length when msgb->lXh is NULL
When any of l1h, l2h, l2h or l4h is set to NULL (which is the default
for newly allocated message buffers). Then the msgb_lXhlen() functions
will return the value of msgb->tail. This is not logical. When the
msgb->lXh pointers are not used then a mgsb_lXhlen() should return 0 and
not a very high random number.
Change-Id: I1795c559f190713ebbabfbabf3453ab77da46a49
Related: OS#5645
---
M include/osmocom/core/msgb.h
1 file changed, 8 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/29591/1
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 117fcb0..8535e04 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -144,6 +144,8 @@
*/
static inline unsigned int msgb_l1len(const struct msgb *msgb)
{
+ if (!msgb->l1h)
+ return 0;
return msgb->tail - (uint8_t *)msgb_l1(msgb);
}
@@ -156,6 +158,8 @@
*/
static inline unsigned int msgb_l2len(const struct msgb *msgb)
{
+ if (!msgb->l2h)
+ return 0;
return msgb->tail - (uint8_t *)msgb_l2(msgb);
}
@@ -168,6 +172,8 @@
*/
static inline unsigned int msgb_l3len(const struct msgb *msgb)
{
+ if (!msgb->l3h)
+ return 0;
return msgb->tail - (uint8_t *)msgb_l3(msgb);
}
@@ -180,6 +186,8 @@
*/
static inline unsigned int msgb_l4len(const struct msgb *msgb)
{
+ if (!msgb->l4h)
+ return 0;
return msgb->tail - (uint8_t *)msgb_sms(msgb);
}
To view, visit change 29591. To unsubscribe, or for help writing mail filters, visit settings.