Change in libosmocore[master]: msgb: dont return a length when msgb->lXh is NULL
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/29591 ) Change subject: msgb: dont return a length when msgb->lXh is NULL ...................................................................... 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 https://gerrit.osmocom.org/c/libosmocore/+/29591 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I1795c559f190713ebbabfbabf3453ab77da46a49 Gerrit-Change-Number: 29591 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
dexter