diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index 97b0fff..75f1a05 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -1193,8 +1193,13 @@ read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t cs = MDCM_PLAIN; } uint8_t *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 8, cs | CMAC_COMMAND); - cs= ocs; + cs = ocs; + /* + * FIXME: This is bogus: the user has to provide a data buffer with enougth + * room to store CRC + padding or MAC. If the user wants to read 1 byte, + * there is no reason to provide a 16 bytes buffer. + */ do { DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res); diff --git a/test/test_mifare_desfire.c b/test/test_mifare_desfire.c index 35e8ef6..7d9630a 100644 --- a/test/test_mifare_desfire.c +++ b/test/test_mifare_desfire.c @@ -914,7 +914,7 @@ test_mifare_desfire_des_macing (void) res = mifare_desfire_write_data (tag, 1, 0, strlen (s), s); cut_assert_success ("mifare_desfire_write_data()"); - char buffer[20]; + char buffer[50]; res = mifare_desfire_read_data (tag, 1, 0, 0, buffer); cut_assert_success ("mifare_desfire_read_data()"); cut_assert_equal_int (20, res, cut_message ("retval"));