<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/19460">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Fix returned data in case of command TPDU<br><br>When Lc>0 (command TPDU), our response always copied the command<br>data in front of the response (which is a SW of 2 bytes in this case).<br><br>This of course confuses the hell out of users.  The response to a Lc>0<br>TPDU should be just the two-bytes status word.<br><br>Introduce the use of msgb->l4h for the point in the buffer from where<br>we receive data from the card.  all bytes before l4h are transmitted<br>to the card.<br><br>Change-Id: Ie3fc7437d39dc330b9f2b7d7960ad2560b6be4b7<br>---<br>M ccid_common/ccid_slot_fsm.c<br>M ccid_common/iso7816_fsm.c<br>2 files changed, 5 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c</span><br><span>index 747fef3..4bd1b0d 100644</span><br><span>--- a/ccid_common/ccid_slot_fsm.c</span><br><span>+++ b/ccid_common/ccid_slot_fsm.c</span><br><span>@@ -172,7 +172,7 @@</span><br><span>              tpdu = data;</span><br><span>                 LOGPCS(cs, LOGL_DEBUG, "%s(event=%d, data=%s)\n", __func__, event,</span><br><span>                         msgb_hexdump(tpdu));</span><br><span style="color: hsl(0, 100%, 40%);">-            resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_OK, 0, msgb_l2(tpdu), msgb_l2len(tpdu));</span><br><span style="color: hsl(120, 100%, 40%);">+           resp = ccid_gen_data_block(cs, ss->seq, CCID_CMD_STATUS_OK, 0, msgb_l4(tpdu), msgb_l4len(tpdu));</span><br><span>          ccid_slot_send_unbusy(cs, resp);</span><br><span>             msgb_free(tpdu);</span><br><span>             cs->event = 0;</span><br><span>diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c</span><br><span>index c76d97d..2796d30 100644</span><br><span>--- a/ccid_common/iso7816_fsm.c</span><br><span>+++ b/ccid_common/iso7816_fsm.c</span><br><span>@@ -1175,9 +1175,13 @@</span><br><span>          /* start transmission of a TPDU by sending the 5-byte header */</span><br><span>              tfp->tpdu = (struct msgb *)data;</span><br><span>          OSMO_ASSERT(msgb_length(tfp->tpdu) >= sizeof(*tpduh));</span><br><span style="color: hsl(120, 100%, 40%);">+          /* l2h = after the 5byte header */</span><br><span>           tfp->tpdu->l2h = msgb_data(tfp->tpdu) + sizeof(*tpduh);</span><br><span style="color: hsl(120, 100%, 40%);">+              /* l4h = where we start to receive from the card */</span><br><span style="color: hsl(120, 100%, 40%);">+           tfp->tpdu->l4h = msgb_l2(tfp->tpdu) + msgb_l2len(tfp->tpdu);</span><br><span>             if (msgb_l2len(tfp->tpdu)) {</span><br><span>                      tfp->is_command = true;</span><br><span style="color: hsl(120, 100%, 40%);">+                    /* l3h = used as 'next byte to write' pointer */</span><br><span>                     tfp->tpdu->l3h = tfp->tpdu->l2h; /* next tx byte == first byte of body */</span><br><span>                } else</span><br><span>                       tfp->is_command = false;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/19460">change 19460</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/osmo-ccid-firmware/+/19460"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ccid-firmware </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ie3fc7437d39dc330b9f2b7d7960ad2560b6be4b7 </div>
<div style="display:none"> Gerrit-Change-Number: 19460 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </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-MessageType: merged </div>