[MERGED] libosmo-sccp[master]: Address some negative integer handling issues

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
Thu Apr 27 09:41:34 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: Address some negative integer handling issues
......................................................................


Address some negative integer handling issues

If for some reason we cannot resolve the file descriptor for a given
FSM, we shouldn't attempt to send data through it.

Fixes: coverity CID#167155, CID#167154, CID#167153, CID#167152, CID#167151, CID#167151
Change-Id: I8b1a676b653bcdad21cb7927d549f499950a2b73
---
M src/xua_asp_fsm.c
1 file changed, 14 insertions(+), 7 deletions(-)

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



diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 2b5bfdd..d54d45e 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -769,8 +769,10 @@
 	case XUA_ASP_E_SCTP_EST_IND:
 		if (iafp->role == XUA_ASPFSM_ROLE_SG) {
 			/* Server: Transmit IPA ID GET + Wait for Response */
-			ipa_ccm_send_id_req(fd);
-			osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_RESP, 10, T_WAIT_ID_RESP);
+			if (fd >= 0) {
+				ipa_ccm_send_id_req(fd);
+				osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_RESP, 10, T_WAIT_ID_RESP);
+			}
 		} else {
 			/* Client: We simply wait for an ID GET */
 			osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_GET, 10, T_WAIT_ID_GET);
@@ -818,8 +820,10 @@
 		osmo_ss7_as_add_asp(as, asp->cfg.name);
 		/* TODO: OAP Authentication? */
 		/* Send ID_ACK */
-		ipaccess_send_id_ack(fd);
-		osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_ACK2, 10, T_WAIT_ID_ACK);
+		if (fd >= 0) {
+			ipaccess_send_id_ack(fd);
+			osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_ACK2, 10, T_WAIT_ID_ACK);
+		}
 		break;
 	}
 	return;
@@ -878,8 +882,10 @@
 	case IPA_ASP_E_ID_ACK:
 		/* Send ACK2 to server */
 		fd = get_fd_from_iafp(iafp);
-		ipaccess_send_id_ack(fd);
-		osmo_fsm_inst_state_chg(fi, IPA_ASP_S_ACTIVE, 0, 0);
+		if (fd >= 0) {
+			ipaccess_send_id_ack(fd);
+			osmo_fsm_inst_state_chg(fi, IPA_ASP_S_ACTIVE, 0, 0);
+		}
 		break;
 	}
 }
@@ -911,7 +917,8 @@
 	case XUA_ASP_E_ASPSM_BEAT:
 		/* PING -> PONG */
 		fd = get_fd_from_iafp(iafp);
-		ipaccess_send_pong(fd);
+		if (fd >= 0)
+			ipaccess_send_pong(fd);
 		break;
 	case XUA_ASP_E_ASPSM_BEAT_ACK:
 		/* stop timer, if any */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8b1a676b653bcdad21cb7927d549f499950a2b73
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
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