aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/gsm0408/gsm0408_test.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-12-14 14:51:40 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-23 12:32:00 +0000
commit881064e9b81de4aee7a9cdd52184860260f8723c (patch)
tree8c6655af403554274bd7a0486e888deda6329303 /openbsc/tests/gsm0408/gsm0408_test.c
parent47e178190744e65079a821f40148eebcaa92bf76 (diff)
Prevent segfault in range encoding
* Explicitly check when ARFCN array split is impossible and return gracefully instead of using negative index. * Separate range encoding into generic function and use it for all SI-related things. * Propagate the error into that function and to its callers. * Add separate test-case for the segfault previously triggered by this bug. Change-Id: I3e049ab2d7c1c4d6c791b148f37e10636a8e43e0 Related: RT#7379
Diffstat (limited to 'openbsc/tests/gsm0408/gsm0408_test.c')
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index ae8cbdd0f..472c2aeef 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -120,6 +120,21 @@ static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn,
gen(bts);
}
+static inline void test_si2q_segfault(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ _bts_uarfcn_add(bts, 10564, 319, 0);
+ _bts_uarfcn_add(bts, 10612, 319, 0);
+ gen(bts);
+}
+
static inline void test_si2q_u(void)
{
struct gsm_bts *bts;
@@ -590,6 +605,7 @@ int main(int argc, char **argv)
test_range_encoding();
test_gsm411_rp_ref_wrap();
+ test_si2q_segfault();
test_si2q_e();
test_si2q_u();
printf("Done.\n");