[MERGED] libosmocore[master]: ctrl_cmd_parse: Make coverity FORWARD_NULL happy

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Nov 26 18:37:57 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: ctrl_cmd_parse: Make coverity FORWARD_NULL happy
......................................................................


ctrl_cmd_parse: Make coverity FORWARD_NULL happy

The 'strtok_r' function requires passing a NULL as the first parameter
on subsequent calls in order to ensure the code picks up where it left
off on a previous call.  However, Coverity doesn't quite realize this
and points out that if a NULL was passed in as the third argument it
would result in a possible NULL deref because the strtok_r function will
assign the third argument to the first in the call is NULL.

Change-Id: I7a9d08d0d4eae76a5207d285e32a25d1b384a57f
Fixes: Coverity CID 135186
---
M src/ctrl/control_cmd.c
1 file changed, 1 insertion(+), 0 deletions(-)

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



diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c
index 3dbcf8f..2cf66cf 100644
--- a/src/ctrl/control_cmd.c
+++ b/src/ctrl/control_cmd.c
@@ -299,6 +299,7 @@
 	msgb_put_u8(msg, 0);
 	str = (char *) msg->l2h;
 
+	OSMO_ASSERT(str);
 	tmp = strtok_r(str, " ",  &saveptr);
 	if (!tmp) {
 		cmd->type = CTRL_TYPE_ERROR;

-- 
To view, visit https://gerrit.osmocom.org/1300
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a9d08d0d4eae76a5207d285e32a25d1b384a57f
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list