summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-10-19 15:50:44 +0200
committerHarald Welte <laforge@gnumonks.org>2017-10-20 18:19:58 +0000
commitfcf81b5deb8d02ba45907e90bb6668c67986a028 (patch)
treef754108de06827156c14f4bb4bb6bb8ef9d9a2a3 /tests
parentd7ee5759cb3296ef32b6dc1858882a122c358165 (diff)
Make osmo_apn_to_str() more robust
Previously it would crash on NULL input. Let's handle it gracefully instead. Corresponding test case is also added. Change-Id: I587153e49d1c92128fac3ae5c124adba9592378e
Diffstat (limited to 'tests')
-rw-r--r--tests/gprs/gprs_test.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/gprs/gprs_test.c b/tests/gprs/gprs_test.c
index be80e5c0..6f16fb2f 100644
--- a/tests/gprs/gprs_test.c
+++ b/tests/gprs/gprs_test.c
@@ -91,6 +91,13 @@ static void test_gsm_03_03_apn(void)
}
{
+ /* NULL input */
+ uint8_t input[] = { 0x1, 65 };
+ char *output = "LOL";
+ OSMO_ASSERT(osmo_apn_to_str(output, NULL, ARRAY_SIZE(input) - 1) == NULL);
+ }
+
+ {
uint8_t input[] = { 0x3, 65, 66, 67, 0x2, 90, 122 };
const char *output = "ABC.Zz";
char tmp[strlen(output) + 1];