Workaround invalid write in read_data () (sic)

This has to be improved to some extend in the near future (hence the FIXME).
This commit is contained in:
Romain Tartiere 2010-12-18 01:05:35 +00:00
parent c9680fd7c7
commit a6e52db696
2 changed files with 7 additions and 2 deletions

View file

@ -1193,8 +1193,13 @@ read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_t offset, size_t
cs = MDCM_PLAIN; cs = MDCM_PLAIN;
} }
uint8_t *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 8, cs | CMAC_COMMAND); 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 { do {
DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res); DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res);

View file

@ -914,7 +914,7 @@ test_mifare_desfire_des_macing (void)
res = mifare_desfire_write_data (tag, 1, 0, strlen (s), s); res = mifare_desfire_write_data (tag, 1, 0, strlen (s), s);
cut_assert_success ("mifare_desfire_write_data()"); cut_assert_success ("mifare_desfire_write_data()");
char buffer[20]; char buffer[50];
res = mifare_desfire_read_data (tag, 1, 0, 0, buffer); res = mifare_desfire_read_data (tag, 1, 0, 0, buffer);
cut_assert_success ("mifare_desfire_read_data()"); cut_assert_success ("mifare_desfire_read_data()");
cut_assert_equal_int (20, res, cut_message ("retval")); cut_assert_equal_int (20, res, cut_message ("retval"));