From 2750ed668c51156e53b5dcbcdcf88828beaf9d55 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Wed, 29 Dec 2010 21:44:26 +0000 Subject: [PATCH] Fix usage of a potentially reallocated memory area. --- libfreefare/mifare_desfire.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index 211aba8..9b887d7 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -823,23 +823,23 @@ mifare_desfire_get_version (MifareTag tag, struct mifare_desfire_version_info *v char buffer[28 + CMAC_LENGTH + 1]; BUFFER_APPEND (cmd, 0x60); - uint8_t *b = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 0, MDCM_PLAIN | CMAC_COMMAND); + uint8_t *p = mifare_cryto_preprocess_data (tag, cmd, &__cmd_n, 0, MDCM_PLAIN | CMAC_COMMAND); - DESFIRE_TRANSCEIVE (tag, cmd, res); + DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res); memcpy (&(version_info->hardware), res, 7); memcpy (buffer, res, 7); - cmd[0] = 0xAF; - DESFIRE_TRANSCEIVE (tag, cmd, res); + p[0] = 0xAF; + DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res); memcpy (&(version_info->software), res, 7); memcpy (buffer + 7, res, 7); - DESFIRE_TRANSCEIVE (tag, cmd, res); + DESFIRE_TRANSCEIVE2 (tag, p, __cmd_n, res); memcpy (&(version_info->uid), res, 14); memcpy (buffer + 14, res, __res_n); ssize_t sn = 28 + CMAC_LENGTH + 1; - b = mifare_cryto_postprocess_data (tag, buffer, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY); + p = mifare_cryto_postprocess_data (tag, buffer, &sn, MDCM_PLAIN | CMAC_COMMAND | CMAC_VERIFY); return 0; }