From aacddc7aae1585d08f6c31d9478cfd8f9ba276c7 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Wed, 31 Mar 2010 22:46:13 +0000 Subject: [PATCH] Add missing htole32() call in mifare_classic_init_value(). Fix Mifare Classic support on big-endian machines. --- libfreefare/mifare_classic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index 470e8c3..72fefbd 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -267,9 +267,11 @@ mifare_classic_init_value (MifareTag tag, const MifareClassicBlockNumber block, { union mifare_classic_block b; - b.value.value = value; - b.value.value_ = ~value; - b.value.value__ = value; + uint32_t le_value = htole32 ((uint32_t)value); + + b.value.value = le_value; + b.value.value_ = ~le_value; + b.value.value__ = le_value; b.value.address = adr; b.value.address_ = ~adr; @@ -349,7 +351,7 @@ mifare_classic_increment (MifareTag tag, const MifareClassicBlockNumber block, c unsigned char command[6]; command[0] = MC_INCREMENT; command[1] = block; - int32_t le_amount = htole32 (amount); + uint32_t le_amount = htole32 (amount); memcpy(&(command[2]), &le_amount, sizeof (le_amount)); // Send command @@ -376,7 +378,7 @@ mifare_classic_decrement (MifareTag tag, const MifareClassicBlockNumber block, c unsigned char command[6]; command[0] = MC_DECREMENT; command[1] = block; - int32_t le_amount = htole32 (amount); + uint32_t le_amount = htole32 (amount); memcpy(&(command[2]), &le_amount, sizeof (le_amount)); // Send command