[PATCH] libosmocore[master]: msgb: msgb_pull: Abort when pulling more than avail size

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Wed Apr 11 18:14:40 UTC 2018


Review at  https://gerrit.osmocom.org/7769

msgb: msgb_pull: Abort when pulling more than avail size

Change-Id: I512ff2035ae7a929e6c96df82938cc1ddbcc4e2a
---
M include/osmocom/core/msgb.h
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/7769/1

diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index a983195..a8dc205 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -331,6 +331,9 @@
  */
 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;
 }

-- 
To view, visit https://gerrit.osmocom.org/7769
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I512ff2035ae7a929e6c96df82938cc1ddbcc4e2a
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list