<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/22349">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gprs_ns2_vc_fsm: fix nullpointer dereference when sending uintdata<br><br>the function gprs_ns2_vc_rx() is called from gprs_ns2.c with tp=NULL.<br>This leads into a null pointer dereference because gprs_ns2_vc_rx() is<br>accessing tp several times. tp is also handed up into the FSM, with the<br>exception of unitdata. Apparently for unitdata tp does not exist, so we<br>can move up the part where unitdata is handed up into the FSM and after<br>that we can check if tp is NULL to make sure the code which is accessing<br>it is not executed.<br><br>Change-Id: I7d7c95604ba4af4ed4b6019f1d432970225f8d7a<br>---<br>M src/gb/gprs_ns2_vc_fsm.c<br>1 file changed, 12 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/49/22349/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c</span><br><span>index d4f4320..7ea7192 100644</span><br><span>--- a/src/gb/gprs_ns2_vc_fsm.c</span><br><span>+++ b/src/gb/gprs_ns2_vc_fsm.c</span><br><span>@@ -756,6 +756,18 @@</span><br><span>          *  if not answer STATUS with "NS-VC unknown" */</span><br><span>   /* TODO: handle BLOCK/UNBLOCK/ALIVE with different VCI */</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (nsh->pdu_type == NS_PDUT_UNITDATA) {</span><br><span style="color: hsl(120, 100%, 40%);">+           /* UNITDATA have to free msg because it might send the msg layer upwards */</span><br><span style="color: hsl(120, 100%, 40%);">+           osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_UNITDATA, msg);</span><br><span style="color: hsl(120, 100%, 40%);">+             return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!tp) {</span><br><span style="color: hsl(120, 100%, 40%);">+            LOGPFSML(fi, LOGL_ERROR, "NSEI=%u Rx %s without TLV IEs\n", nsvc->nse->nsei,</span><br><span style="color: hsl(120, 100%, 40%);">+                   get_value_string(gprs_ns_pdu_strings, nsh->pdu_type));</span><br><span style="color: hsl(120, 100%, 40%);">+            goto out;</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (gprs_ns2_validate(nsvc, nsh->pdu_type, msg, tp, &cause)) {</span><br><span>                if (nsh->pdu_type != NS_PDUT_STATUS) {</span><br><span>                    rc = ns2_tx_status(nsvc, cause, 0, msg);</span><br><span>@@ -814,10 +826,6 @@</span><br><span>      case NS_PDUT_ALIVE_ACK:</span><br><span>              osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_ALIVE_ACK, tp);</span><br><span>            break;</span><br><span style="color: hsl(0, 100%, 40%);">-  case NS_PDUT_UNITDATA:</span><br><span style="color: hsl(0, 100%, 40%);">-          /* UNITDATA have to free msg because it might send the msg layer upwards */</span><br><span style="color: hsl(0, 100%, 40%);">-             osmo_fsm_inst_dispatch(fi, GPRS_NS2_EV_RX_UNITDATA, msg);</span><br><span style="color: hsl(0, 100%, 40%);">-               return 0;</span><br><span>    default:</span><br><span>             LOGPFSML(fi, LOGL_ERROR, "NSEI=%u Rx unknown NS PDU type %s\n", nsvc->nse->nsei,</span><br><span>                      get_value_string(gprs_ns_pdu_strings, nsh->pdu_type));</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/22349">change 22349</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/22349"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I7d7c95604ba4af4ed4b6019f1d432970225f8d7a </div>
<div style="display:none"> Gerrit-Change-Number: 22349 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>