scd: Shorten cardio debug output for all zeroes.

* scd/apdu.c (all_zero_p): New.
(send_le): Use it.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 9b6f574928)
This commit is contained in:
Werner Koch 2020-06-29 15:01:43 +02:00
parent 7bc794c311
commit 62becf599e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 33 additions and 4 deletions

View File

@ -366,9 +366,23 @@ static int pcsc_pinpad_modify (int slot, int class, int ins, int p0, int p1,
/* /*
Helper * Helper
*/ */
/* Return true if (BUFFER,LENGTH) consists of only binary zeroes. */
static int
all_zero_p (const void *buffer, size_t length)
{
const unsigned char *p;
for (p=buffer; length; p++, length--)
if (*p)
return 0;
return 1;
}
static int static int
lock_slot (int slot) lock_slot (int slot)
{ {
@ -3009,7 +3023,12 @@ send_le (int slot, int class, int ins, int p0, int p1,
log_debug (" response: sw=%04X datalen=%d\n", log_debug (" response: sw=%04X datalen=%d\n",
sw, (unsigned int)resultlen); sw, (unsigned int)resultlen);
if ( !retbuf && (sw == SW_SUCCESS || (sw & 0xff00) == SW_MORE_DATA)) if ( !retbuf && (sw == SW_SUCCESS || (sw & 0xff00) == SW_MORE_DATA))
log_printhex (result, resultlen, " dump: "); {
if (all_zero_p (result, resultlen))
log_debug (" dump: [all zero]\n");
else
log_printhex (result, resultlen, " dump:");
}
} }
if (sw == SW_SUCCESS || sw == SW_EOF_REACHED) if (sw == SW_SUCCESS || sw == SW_EOF_REACHED)
@ -3082,7 +3101,12 @@ send_le (int slot, int class, int ins, int p0, int p1,
log_debug (" more: sw=%04X datalen=%d\n", log_debug (" more: sw=%04X datalen=%d\n",
sw, (unsigned int)resultlen); sw, (unsigned int)resultlen);
if (!retbuf && (sw==SW_SUCCESS || (sw&0xff00)==SW_MORE_DATA)) if (!retbuf && (sw==SW_SUCCESS || (sw&0xff00)==SW_MORE_DATA))
log_printhex (result, resultlen, " dump: "); {
if (all_zero_p (result, resultlen))
log_debug ( " dump: [all zero]\n");
else
log_printhex (result, resultlen, " dump:");
}
} }
if ((sw & 0xff00) == SW_MORE_DATA if ((sw & 0xff00) == SW_MORE_DATA
@ -3128,7 +3152,12 @@ send_le (int slot, int class, int ins, int p0, int p1,
xfree (result_buffer); xfree (result_buffer);
if (DBG_CARD_IO && retbuf && sw == SW_SUCCESS) if (DBG_CARD_IO && retbuf && sw == SW_SUCCESS)
log_printhex (*retbuf, *retbuflen, " dump: "); {
if (all_zero_p (*retbuf, *retbuflen))
log_debug (" dump: [all zero]\n");
else
log_printhex (*retbuf, *retbuflen, " dump:");
}
return sw; return sw;
} }