summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-04-11 20:14:08 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-04-11 20:14:08 +0200
commitc62fc2d20f433117a123ec43862263c02013b460 (patch)
treedf6805a54c67bac1039b879cb8a0df30a335674e
parent9fa0912e5b8c38bd4ea973cd7224a5a8b4b26c5f (diff)
msgb: msgb_pull: Abort when pulling more than avail size
Change-Id: I512ff2035ae7a929e6c96df82938cc1ddbcc4e2a
-rw-r--r--include/osmocom/core/msgb.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index a9831957..a8dc205b 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -331,6 +331,9 @@ static inline void msgb_push_u32(struct msgb *msg, uint32_t word)
*/
static inline unsigned char *msgb_pull(struct msgb *msgb, unsigned int len)
{
+ if (msgb_length(msgb) < len)
+ MSGB_ABORT(msgb, "msgb too small to pull %u (len %u)\n",
+ len, msgb_length(msgb));
msgb->len -= len;
return msgb->data += len;
}