Change in osmo-msc[master]: libmsc/ran_msg_a.c: avoid ternary operator in struct initialization

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon May 13 20:15:06 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13979 )

Change subject: libmsc/ran_msg_a.c: avoid ternary operator in struct initialization
......................................................................

libmsc/ran_msg_a.c: avoid ternary operator in struct initialization

For some reason, having ternary operator there makes Coverity think
that 'n->geran.chosen_encryption' is dereferenced before checking
against NULL. Let's make it happy, and move the assignment.

Change-Id: I95051d0f02e2fdd3ec8da3a506109e7b23e99b4b
Fixes: CID#198454 Dereference before null check
---
M src/libmsc/ran_msg_a.c
1 file changed, 1 insertion(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libmsc/ran_msg_a.c b/src/libmsc/ran_msg_a.c
index ba0990d..da32a84 100644
--- a/src/libmsc/ran_msg_a.c
+++ b/src/libmsc/ran_msg_a.c
@@ -1068,9 +1068,6 @@
 
 		.speech_version_used = n->speech_version_used,
 
-		.chosen_encryption_algorithm_serving =
-			n->geran.chosen_encryption ? n->geran.chosen_encryption->alg_id : 0,
-
 		.old_bss_to_new_bss_info_raw = n->old_bss_to_new_bss_info_raw,
 		.old_bss_to_new_bss_info_raw_len = n->old_bss_to_new_bss_info_raw_len,
 
@@ -1098,6 +1095,7 @@
 		memcpy(r.encryption_information.key,
 		       n->geran.chosen_encryption->key, n->geran.chosen_encryption->key_len);
 		r.encryption_information.key_len = n->geran.chosen_encryption->key_len;
+		r.chosen_encryption_algorithm_serving = n->geran.chosen_encryption->alg_id;
 	}
 
 	if (n->classmark)

-- 
To view, visit https://gerrit.osmocom.org/13979
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I95051d0f02e2fdd3ec8da3a506109e7b23e99b4b
Gerrit-Change-Number: 13979
Gerrit-PatchSet: 4
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190513/82badbb2/attachment.html>


More information about the gerrit-log mailing list