Review at  https://gerrit.osmocom.org/2422

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(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/22/2422/1

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: newchange
Gerrit-Change-Id: I8b1a676b653bcdad21cb7927d549f499950a2b73
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to