summaryrefslogtreecommitdiffstats
path: root/src/gsm
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 /src/gsm
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 'src/gsm')
-rw-r--r--src/gsm/apn.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gsm/apn.c b/src/gsm/apn.c
index 8d4b2bfc..f8303db9 100644
--- a/src/gsm/apn.c
+++ b/src/gsm/apn.c
@@ -53,6 +53,9 @@ char * osmo_apn_to_str(char *out_str, const uint8_t *apn_enc, size_t apn_enc_len
char *str = out_str;
size_t rest_chars = apn_enc_len;
+ if (!apn_enc)
+ return NULL;
+
while (rest_chars > 0 && apn_enc[0]) {
size_t label_size = apn_enc[0];
if (label_size + 1 > rest_chars)