1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-09 21:28:51 +01:00

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>
This commit is contained in:
Werner Koch 2020-06-29 15:01:43 +02:00
parent 4f1c257c03
commit 9b6f574928
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -363,9 +363,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)
{ {
@ -2925,8 +2939,13 @@ 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))
{
if (all_zero_p (result, resultlen))
log_debug (" dump: [all zero]\n");
else
log_printhex (result, resultlen, " dump:"); log_printhex (result, resultlen, " dump:");
} }
}
if (sw == SW_SUCCESS || sw == SW_EOF_REACHED) if (sw == SW_SUCCESS || sw == SW_EOF_REACHED)
{ {
@ -2998,8 +3017,13 @@ 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))
{
if (all_zero_p (result, resultlen))
log_debug ( " dump: [all zero]\n");
else
log_printhex (result, resultlen, " dump:"); log_printhex (result, resultlen, " dump:");
} }
}
if ((sw & 0xff00) == SW_MORE_DATA if ((sw & 0xff00) == SW_MORE_DATA
|| sw == SW_SUCCESS || sw == SW_SUCCESS
@ -3044,7 +3068,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)
{
if (all_zero_p (*retbuf, *retbuflen))
log_debug (" dump: [all zero]\n");
else
log_printhex (*retbuf, *retbuflen, " dump:"); log_printhex (*retbuf, *retbuflen, " dump:");
}
return sw; return sw;
} }