From 7ba89daae6b5ad8a78c4bf7e10796953a9017313 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Wed, 3 Feb 2021 21:30:01 +0100 Subject: [PATCH] apdu: Do not insert delay while fuzzing This was timeout after 60 seconds. After skipping this call, we get down to 1 s for the same input Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27423 --- src/libopensc/apdu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libopensc/apdu.c b/src/libopensc/apdu.c index 0e3f2f2c..b52183ea 100644 --- a/src/libopensc/apdu.c +++ b/src/libopensc/apdu.c @@ -401,11 +401,13 @@ sc_set_le_and_transmit(struct sc_card *card, struct sc_apdu *apdu, size_t olen) /* set the new expected length */ apdu->resplen = olen; apdu->le = nlen; +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION /* Belpic V1 applets have a problem: if the card sends a 6C XX (only XX bytes available), * and we resend the command too soon (i.e. the reader is too fast), the card doesn't respond. * So we build in a delay. */ if (card->type == SC_CARD_TYPE_BELPIC_EID) msleep(40); +#endif /* re-transmit the APDU with new Le length */ rv = sc_single_transmit(card, apdu);