replace deprecated bzero function by memset.
This commit is contained in:
parent
0e2bc992bf
commit
5133491c2c
7 changed files with 16 additions and 16 deletions
|
@ -38,7 +38,7 @@ AC_FUNC_MALLOC
|
||||||
AC_FUNC_REALLOC
|
AC_FUNC_REALLOC
|
||||||
|
|
||||||
AC_CHECK_HEADERS([sys/types.h])
|
AC_CHECK_HEADERS([sys/types.h])
|
||||||
AC_CHECK_FUNCS([bzero memset letoh32 htole32 pow strerror])
|
AC_CHECK_FUNCS([memset letoh32 htole32 pow strerror])
|
||||||
|
|
||||||
AC_CHECK_HEADERS([endian.h sys/endian.h CoreFoundation/CoreFoundation.h])
|
AC_CHECK_HEADERS([endian.h sys/endian.h CoreFoundation/CoreFoundation.h])
|
||||||
if test $ac_cv_header_endian_h = "no" -a $ac_cv_header_sys_endian_h = "no" -a $ac_cv_header_CoreFoundation_CoreFoundation_h = "no"; then
|
if test $ac_cv_header_endian_h = "no" -a $ac_cv_header_sys_endian_h = "no" -a $ac_cv_header_CoreFoundation_CoreFoundation_h = "no"; then
|
||||||
|
|
|
@ -117,8 +117,8 @@ mad_new (uint8_t version)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
mad->version = version;
|
mad->version = version;
|
||||||
bzero (&(mad->sector_0x00), sizeof (mad->sector_0x00));
|
memset (&(mad->sector_0x00), 0, sizeof (mad->sector_0x00));
|
||||||
bzero (&(mad->sector_0x10), sizeof (mad->sector_0x10));
|
memset (&(mad->sector_0x10), 0, sizeof (mad->sector_0x10));
|
||||||
|
|
||||||
return mad;
|
return mad;
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ mad_set_version (Mad mad, const uint8_t version)
|
||||||
{
|
{
|
||||||
if ((version == 2) && (mad->version == 1)) {
|
if ((version == 2) && (mad->version == 1)) {
|
||||||
/* We use a larger MAD so initialise the new blocks */
|
/* We use a larger MAD so initialise the new blocks */
|
||||||
bzero (&(mad->sector_0x10), sizeof (mad->sector_0x10));
|
memset (&(mad->sector_0x10), 0, sizeof (mad->sector_0x10));
|
||||||
}
|
}
|
||||||
mad->version = version;
|
mad->version = version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,7 +675,7 @@ mifare_classic_format_sector (MifareTag tag, const MifareClassicSectorNumber sec
|
||||||
}
|
}
|
||||||
|
|
||||||
MifareClassicBlock empty_data_block;
|
MifareClassicBlock empty_data_block;
|
||||||
bzero (empty_data_block, sizeof (empty_data_block));
|
memset (empty_data_block, 0, sizeof (empty_data_block));
|
||||||
|
|
||||||
MifareClassicBlock default_trailer_block = {
|
MifareClassicBlock default_trailer_block = {
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* Key A */
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* Key A */
|
||||||
|
|
|
@ -330,7 +330,7 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key
|
||||||
ASSERT_ACTIVE (tag);
|
ASSERT_ACTIVE (tag);
|
||||||
ASSERT_MIFARE_DESFIRE (tag);
|
ASSERT_MIFARE_DESFIRE (tag);
|
||||||
|
|
||||||
bzero (MIFARE_DESFIRE (tag)->ivect, MAX_CRYPTO_BLOCK_SIZE);
|
memset (MIFARE_DESFIRE (tag)->ivect, 0, MAX_CRYPTO_BLOCK_SIZE);
|
||||||
|
|
||||||
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ mifare_desfire_authenticate (MifareTag tag, uint8_t key_no, MifareDESFireKey key
|
||||||
|
|
||||||
MIFARE_DESFIRE (tag)->authenticated_key_no = key_no;
|
MIFARE_DESFIRE (tag)->authenticated_key_no = key_no;
|
||||||
MIFARE_DESFIRE (tag)->session_key = mifare_desfire_session_key_new (PCD_RndA, PICC_RndB, key);
|
MIFARE_DESFIRE (tag)->session_key = mifare_desfire_session_key_new (PCD_RndA, PICC_RndB, key);
|
||||||
bzero (MIFARE_DESFIRE (tag)->ivect, MAX_CRYPTO_BLOCK_SIZE);
|
memset (MIFARE_DESFIRE (tag)->ivect, 0, MAX_CRYPTO_BLOCK_SIZE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ mifare_desfire_change_key_settings (MifareTag tag, uint8_t settings)
|
||||||
|
|
||||||
data[0] = settings;
|
data[0] = settings;
|
||||||
iso14443a_crc (data, 1, data + 1);
|
iso14443a_crc (data, 1, data + 1);
|
||||||
bzero (data+3, 5);
|
memset (data+3, 0, 5);
|
||||||
|
|
||||||
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, data, 8, MD_SEND, 0);
|
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, data, 8, MD_SEND, 0);
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ mifare_desfire_change_key (MifareTag tag, uint8_t key_no, MifareDESFireKey new_k
|
||||||
if (old_key) {
|
if (old_key) {
|
||||||
memcpy (data, old_key->data, 16);
|
memcpy (data, old_key->data, 16);
|
||||||
} else {
|
} else {
|
||||||
bzero (data, 16);
|
memset (data, 0, 16);
|
||||||
}
|
}
|
||||||
for (int n=0; n<16; n++) {
|
for (int n=0; n<16; n++) {
|
||||||
data[n] ^= new_key->data[n];
|
data[n] ^= new_key->data[n];
|
||||||
|
@ -809,7 +809,7 @@ mifare_desfire_change_file_settings (MifareTag tag, uint8_t file_no, uint8_t com
|
||||||
uint16_t le_ar = htole16 (access_rights);
|
uint16_t le_ar = htole16 (access_rights);
|
||||||
memcpy (data + 1, &le_ar, sizeof (le_ar));
|
memcpy (data + 1, &le_ar, sizeof (le_ar));
|
||||||
iso14443a_crc (data, 3, data+3);
|
iso14443a_crc (data, 3, data+3);
|
||||||
bzero (data + 5, 3);
|
memset (data + 5, 0, 3);
|
||||||
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, data, 8, MD_SEND, 0);
|
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, data, 8, MD_SEND, 0);
|
||||||
|
|
||||||
BUFFER_APPEND_BYTES (cmd, data, 8);
|
BUFFER_APPEND_BYTES (cmd, data, 8);
|
||||||
|
|
|
@ -152,7 +152,7 @@ mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t o
|
||||||
// Fill in the crypto buffer with data ...
|
// Fill in the crypto buffer with data ...
|
||||||
memcpy (res, data, *nbytes);
|
memcpy (res, data, *nbytes);
|
||||||
// ... and 0 padding
|
// ... and 0 padding
|
||||||
bzero ((uint8_t *)res + *nbytes, edl - *nbytes);
|
memset ((uint8_t *)res + *nbytes, 0, edl - *nbytes);
|
||||||
|
|
||||||
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, (uint8_t *) res + offset, edl - offset, MD_SEND, 1);
|
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, (uint8_t *) res + offset, edl - offset, MD_SEND, 1);
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ mifare_cryto_preprocess_data (MifareTag tag, void *data, size_t *nbytes, off_t o
|
||||||
// ... CRC ...
|
// ... CRC ...
|
||||||
iso14443a_crc_append ((uint8_t *)res + offset, *nbytes - offset);
|
iso14443a_crc_append ((uint8_t *)res + offset, *nbytes - offset);
|
||||||
// ... and 0 padding
|
// ... and 0 padding
|
||||||
bzero ((uint8_t *)(res) + *nbytes + 2, edl - *nbytes - 2);
|
memset ((uint8_t *)(res) + *nbytes + 2, 0, edl - *nbytes - 2);
|
||||||
|
|
||||||
*nbytes = edl;
|
*nbytes = edl;
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ mifare_cryto_postprocess_data (MifareTag tag, void *data, ssize_t *nbytes, int c
|
||||||
edata = malloc (edl);
|
edata = malloc (edl);
|
||||||
|
|
||||||
memcpy (edata, data, *nbytes);
|
memcpy (edata, data, *nbytes);
|
||||||
bzero ((uint8_t *)edata + *nbytes, edl - *nbytes);
|
memset ((uint8_t *)edata + *nbytes, 0, edl - *nbytes);
|
||||||
|
|
||||||
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, edata, edl, MD_SEND, 1);
|
mifare_cbc_des (MIFARE_DESFIRE (tag)->session_key, MIFARE_DESFIRE (tag)->ivect, edata, edl, MD_SEND, 1);
|
||||||
/* ,^^^^^^^
|
/* ,^^^^^^^
|
||||||
|
@ -328,7 +328,7 @@ mifare_cbc_des (MifareDESFireKey key, uint8_t *ivect, uint8_t *data, size_t data
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
case T_DES:
|
case T_DES:
|
||||||
case T_3DES:
|
case T_3DES:
|
||||||
bzero (ivect, MAX_CRYPTO_BLOCK_SIZE);
|
memset (ivect, 0, MAX_CRYPTO_BLOCK_SIZE);
|
||||||
block_size = 8;
|
block_size = 8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ test_mifare_classic_format (void)
|
||||||
};
|
};
|
||||||
|
|
||||||
MifareClassicBlock empty;
|
MifareClassicBlock empty;
|
||||||
bzero (empty, sizeof (empty));
|
memset (empty, 0, sizeof (empty));
|
||||||
|
|
||||||
res = mifare_classic_write (tag, 0x3c, data);
|
res = mifare_classic_write (tag, 0x3c, data);
|
||||||
cut_assert_equal_int (0, res, cut_message ("mifare_classic_write() failed"));
|
cut_assert_equal_int (0, res, cut_message ("mifare_classic_write() failed"));
|
||||||
|
|
|
@ -198,7 +198,7 @@ test_mifare_desfire (void)
|
||||||
|
|
||||||
// Ensure that no content was changed yet
|
// Ensure that no content was changed yet
|
||||||
char ref_buffer[64];
|
char ref_buffer[64];
|
||||||
bzero (ref_buffer, sizeof (ref_buffer));
|
memset (ref_buffer, 0, sizeof (ref_buffer));
|
||||||
for (int n = 0; n < transaction; n++) {
|
for (int n = 0; n < transaction; n++) {
|
||||||
sprintf (ref_buffer + 3 * n, "%02d", n);
|
sprintf (ref_buffer + 3 * n, "%02d", n);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue