From f6e56058f4fe8497d39b78f14ad61e00ecad4430 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 25 Apr 2016 13:12:58 +0200 Subject: [PATCH] ranap_parse_lai(): properly initialize out-arg, adjust test experr The test stderr output changes merely because the source code line numbers of the error logging changed. Fixes: CID#93770 --- src/ranap_common.c | 4 ++++ src/tests/test-helpers.err | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ranap_common.c b/src/ranap_common.c index dc464591..a468229f 100644 --- a/src/ranap_common.c +++ b/src/ranap_common.c @@ -498,6 +498,10 @@ int ranap_parse_lai(struct gprs_ra_id *ra_id, const RANAP_LAI_t *lai) { uint8_t *ptr = lai->pLMNidentity.buf; + /* Avoid unitialized mem for parse failures, and set rac to zero (which + * isn't being parsed). */ + *ra_id = (struct gprs_ra_id){ .lac = 0xfffe }; + /* TS 25.413 9.2.3.55 */ if (lai->pLMNidentity.size != 3) { LOGP(DRANAP, LOGL_ERROR, "Invalid PLMN Identity size:" diff --git a/src/tests/test-helpers.err b/src/tests/test-helpers.err index 9c04723d..81b79e19 100644 --- a/src/tests/test-helpers.err +++ b/src/tests/test-helpers.err @@ -1,3 +1,3 @@ -<0004> ranap_common.c:504 Invalid PLMN Identity size: should be 3, is 2 -<0004> ranap_common.c:518 Invalid LAC size: should be 2, is 1 +<0004> ranap_common.c:508 Invalid PLMN Identity size: should be 3, is 2 +<0004> ranap_common.c:522 Invalid LAC size: should be 2, is 1  \ No newline at end of file