Change in libosmocore[master]: msgb_alloc_headroom: Validate size arg fits a uint16_t

pespin gerrit-no-reply at lists.osmocom.org
Thu Jun 10 12:50:46 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24641 )


Change subject: msgb_alloc_headroom: Validate size arg fits a uint16_t
......................................................................

msgb_alloc_headroom: Validate size arg fits a uint16_t

Underlaying APIs (msgb_alloc) use a uint16_t as a type, which means
until now passing a value > 2^16 would succeed providing a msgb with
less space than requested.

Since those are static inline, there's no symbols used by apps, so we
should be safe enough changing the type to be uint16_t, since change
would only be applied at re-compile time.

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



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/24641/1

diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index cc76e3a..df796c9 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -524,7 +524,7 @@
  * followed by \ref msgb_reserve in order to create a new \ref msgb with
  * user-specified amount of headroom.
  */
-static inline struct msgb *msgb_alloc_headroom_c(const void *ctx, int size, int headroom,
+static inline struct msgb *msgb_alloc_headroom_c(const void *ctx, uint16_t size, uint16_t headroom,
 						 const char *name)
 {
 	osmo_static_assert(size >= headroom, headroom_bigger);
@@ -546,7 +546,7 @@
  * followed by \ref msgb_reserve in order to create a new \ref msgb with
  * user-specified amount of headroom.
  */
-static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
+static inline struct msgb *msgb_alloc_headroom(uint16_t size, uint16_t headroom,
 						const char *name)
 {
 	osmo_static_assert(size >= headroom, headroom_bigger);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24641
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I83c8222484e4856c68134a1a9d8cf96eb91af1b8
Gerrit-Change-Number: 24641
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210610/b06e9180/attachment.htm>


More information about the gerrit-log mailing list