<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/17269">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo-sim-test: check tlv_parsed struct tp before access<br><br>The variable struct tlv_parsed tp in dump_file() conditionally<br>initalized by tlv_parse() but later it is accessed under a different<br>condition without a check that makes sure that tp is only accessed when<br>tlv_parse() was called beforehand. Lets introduce a check that makes<br>sure tp can not be accessed when it is uninitalized.<br><br>Change-Id: I6b0209b966127a4195e6f4bcb43d49387c7646ce<br>Fixes: CID#208435<br>---<br>M utils/osmo-sim-test.c<br>1 file changed, 8 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c</span><br><span>index d33f1ba..27de0bc 100644</span><br><span>--- a/utils/osmo-sim-test.c</span><br><span>+++ b/utils/osmo-sim-test.c</span><br><span>@@ -378,11 +378,15 @@</span><br><span>             }</span><br><span>            break;</span><br><span>       case EF_TYPE_TRANSP:</span><br><span style="color: hsl(0, 100%, 40%);">-            if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE))</span><br><span style="color: hsl(120, 100%, 40%);">+             if (g_class != 0xA0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE))</span><br><span style="color: hsl(120, 100%, 40%);">+                             goto out;</span><br><span style="color: hsl(120, 100%, 40%);">+                     i = ntohs(*(uint16_t *)TLVP_VAL(&tp, UICC_FCP_T_FILE_SIZE));</span><br><span style="color: hsl(120, 100%, 40%);">+                      printf("File size: %d bytes\n", i);</span><br><span style="color: hsl(120, 100%, 40%);">+         } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      printf("Can not determine file size, invalid EF-type!\n");</span><br><span>                         goto out;</span><br><span style="color: hsl(0, 100%, 40%);">-               i = ntohs(*(uint16_t *)TLVP_VAL(&tp, UICC_FCP_T_FILE_SIZE));</span><br><span style="color: hsl(0, 100%, 40%);">-                printf("File size: %d bytes\n", i);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span>            for (offset = 0; offset < i-1; ) {</span><br><span>                        uint16_t remain_len = i - offset;</span><br><span>                    uint16_t read_len = OSMO_MIN(remain_len, 256);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/17269">change 17269</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/+/17269"/><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: I6b0209b966127a4195e6f4bcb43d49387c7646ce </div>
<div style="display:none"> Gerrit-Change-Number: 17269 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>