Harald Welte has uploaded this change for review. ( 
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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/48/10848/1

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: newchange
Gerrit-Change-Id: I85fdecbf20de83a6f925765a46b5cd14765da03e
Gerrit-Change-Number: 10848
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to