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/.
Max gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/4354 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 --- M src/gsm/apn.c M tests/gprs/gprs_test.c 2 files changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/4354/1 diff --git a/src/gsm/apn.c b/src/gsm/apn.c index 8d4b2bf..f8303db 100644 --- a/src/gsm/apn.c +++ b/src/gsm/apn.c @@ -53,6 +53,9 @@ 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) diff --git a/tests/gprs/gprs_test.c b/tests/gprs/gprs_test.c index be80e5c..e06761c 100644 --- a/tests/gprs/gprs_test.c +++ b/tests/gprs/gprs_test.c @@ -91,6 +91,13 @@ } { + /* NULL input */ + uint8_t input[] = { 0x1, 65 }; + const 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]; -- To view, visit https://gerrit.osmocom.org/4354 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I587153e49d1c92128fac3ae5c124adba9592378e Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de>