Change in osmo-mgw[master]: mgcp: Fix osmux_cid_bitmap static array size calculation

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 Sep 19 10:46:54 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/10995 )

Change subject: mgcp: Fix osmux_cid_bitmap static array size calculation
......................................................................

mgcp: Fix osmux_cid_bitmap static array size calculation

Right now it's not a big issue since OSMUX_CID_MAX is 255, so 255+1 is
256 which fits array boundaries correctly (multiple of 8). However, if
for example OSMUX_CID_MAX was modified to be 12, 12+1/8 = 1, so we'd
have an undesired memory access when accessing last 4 CIDs.

A +1 should be kept on top, because OSMUX_CID_MAX specified the maximum
number used by a CID, that is (0,OSMUX_CID_MAX), and as a result we
require OSMUX_CID_MAX+1 slots.

Change-Id: Iaf9b93712dbd2a862b01e70dd8e11893bfa6b24c
---
M src/libosmo-mgcp/mgcp_osmux.c
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 26817c8..5d16826 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -655,8 +655,8 @@
 			     htons(endp->cfg->osmux_port), buf, sizeof(buf));
 }
 
-/*! bsc-nat allocates/releases the OSMUX cids (Circuit IDs). */
-static uint8_t osmux_cid_bitmap[(OSMUX_CID_MAX + 1) / 8];
+/* bsc-nat allocates/releases the Osmux circuit ID. +7 to round up to 8 bit boundary. */
+static uint8_t osmux_cid_bitmap[(OSMUX_CID_MAX + 1 + 7) / 8];
 
 /*! count the number of taken OSMUX cids.
  *  \returns number of OSMUX cids in use */

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf9b93712dbd2a862b01e70dd8e11893bfa6b24c
Gerrit-Change-Number: 10995
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180919/f89ff1d7/attachment.htm>


More information about the gerrit-log mailing list