Index: src/libopensc/apdu.c =================================================================== --- src/libopensc/apdu.c (revision 4778) +++ src/libopensc/apdu.c (working copy) @@ -490,7 +490,8 @@ SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r); if (buflen < le) - return SC_ERROR_WRONG_LENGTH; + /* copy as much as will fit in requested buffer */ + le = buflen; memcpy(buf, tbuf, le); buf += le;