Change in osmo-bts[master]: CBCH: sprinkle some OMSO_ASSERT() and guard against talloc failure

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Sep 17 20:02:06 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10848 )

Change subject: CBCH: sprinkle some OMSO_ASSERT() and guard against talloc failure
......................................................................

CBCH: sprinkle some OMSO_ASSERT() and guard against talloc failure

Change-Id: I85fdecbf20de83a6f925765a46b5cd14765da03e
---
M src/common/cbch.c
1 file changed, 5 insertions(+), 0 deletions(-)

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



diff --git a/src/common/cbch.c b/src/common/cbch.c
index 7bbe2c9..c628cb5 100644
--- a/src/common/cbch.c
+++ b/src/common/cbch.c
@@ -20,6 +20,7 @@
 
 #include <errno.h>
 
+#include <osmocom/core/utils.h>
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/gsm/protocol/gsm_04_12.h>
 
@@ -59,6 +60,7 @@
 		/* No message: Send NULL mesage */
 		return get_smscb_null_block(out);
 	}
+	OSMO_ASSERT(msg->next_seg < 4);
 
 	block_type = (struct gsm412_block_type *) out++;
 
@@ -70,6 +72,7 @@
 	to_copy = GSM412_MSG_LEN - (msg->next_seg * GSM412_BLOCK_LEN);
 	if (to_copy > GSM412_BLOCK_LEN)
 		to_copy = GSM412_BLOCK_LEN;
+	OSMO_ASSERT(to_copy >= 0);
 
 	/* copy data and increment index */
 	memcpy(out, &msg->msg[msg->next_seg * GSM412_BLOCK_LEN], to_copy);
@@ -115,6 +118,8 @@
 	}
 
 	scm = talloc_zero_size(bts, sizeof(*scm));
+	if (!scm)
+		return -1;
 
 	/* initialize entire message with default padding */
 	memset(scm->msg, GSM_MACBLOCK_PADDING, sizeof(scm->msg));

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I85fdecbf20de83a6f925765a46b5cd14765da03e
Gerrit-Change-Number: 10848
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180917/bbdccafd/attachment.htm>


More information about the gerrit-log mailing list