diff --git a/client/Makefile b/client/Makefile index 48a1a3591..9904e8b27 100644 --- a/client/Makefile +++ b/client/Makefile @@ -58,9 +58,9 @@ INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS) #CFLAGS ?= -Wall -Werror -O3 ifeq ($(platform),Darwin) # readline has strict-prototype issues -CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations +CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wno-error=cast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wnested-externs -Wmissing-declarations else -CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wstrict-prototypes -Wnested-externs -Wmissing-declarations +CFLAGS ?= -Wall -Werror -O3 -Wredundant-decls -Wmissing-prototypes -Wchar-subscripts -Wundef -Wcast-align -Wno-error=cast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wstrict-prototypes -Wnested-externs -Wmissing-declarations endif # -Wshadow # -Wbad-function-cast -Wextra -Wswitch-enum -Wold-style-definition diff --git a/client/deps/cliparser/Makefile b/client/deps/cliparser/Makefile index 7f4409de0..4873372c4 100644 --- a/client/deps/cliparser/Makefile +++ b/client/deps/cliparser/Makefile @@ -1,6 +1,6 @@ MYSRCPATHS = MYINCLUDES = -I../../../common -I../../../include -I../../src -MYCFLAGS = +MYCFLAGS = -Wno-cast-align MYDEFS = MYSRCS = \ argtable3.c \ diff --git a/client/deps/jansson/Makefile b/client/deps/jansson/Makefile index 152e8bcb9..c0d16d6a3 100644 --- a/client/deps/jansson/Makefile +++ b/client/deps/jansson/Makefile @@ -1,6 +1,6 @@ MYSRCPATHS = MYINCLUDES = -I. -MYCFLAGS = -Wno-unused-function +MYCFLAGS = -Wno-unused-function -Wno-cast-align MYDEFS = -DHAVE_STDINT_H MYSRCS = \ dump.c \ diff --git a/client/deps/liblua/Makefile b/client/deps/liblua/Makefile index 54e45185b..0b05279b7 100644 --- a/client/deps/liblua/Makefile +++ b/client/deps/liblua/Makefile @@ -1,7 +1,7 @@ MYSRCPATHS = MYINCLUDES = -I. # Lua lib requires GNU extensions (implicit declarations of functions): -std=gnu99 or -std=gnu11 -MYCFLAGS = +MYCFLAGS = -Wno-cast-align MYDEFS = -DLUA_COMPAT_ALL $(SYSCFLAGS) MYSRCS = lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c \ lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c \ diff --git a/client/src/mifare/mfkey.c b/client/src/mifare/mfkey.c index 7d04762b8..710bba449 100644 --- a/client/src/mifare/mfkey.c +++ b/client/src/mifare/mfkey.c @@ -45,11 +45,14 @@ uint32_t intersection(uint64_t *listA, uint64_t *listB) { // Darkside attack (hf mf mifare) // if successful it will return a list of keys, not just one. uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par_info, uint64_t ks_info, uint64_t **keys) { - struct Crypto1State *states; + union { + struct Crypto1State *states; + uint64_t *keylist; + } unionstate; + uint32_t i, pos; uint8_t ks3x[8], par[8][8]; uint64_t key_recovered; - uint64_t *keylist; // Reset the last three significant bits of the reader nonce nr &= 0xFFFFFF1F; @@ -68,23 +71,21 @@ uint32_t nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint32_t ar, uint64_t par[7 - pos][7] = (bt >> 7) & 1; } - states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0)); + unionstate.states = lfsr_common_prefix(nr, ar, ks3x, par, (par_info == 0)); - if (!states) { + if (!unionstate.states) { *keys = NULL; return 0; } - keylist = (uint64_t *)states; - - for (i = 0; keylist[i]; i++) { - lfsr_rollback_word(states + i, uid ^ nt, 0); - crypto1_get_lfsr(states + i, &key_recovered); - keylist[i] = key_recovered; + for (i = 0; unionstate.keylist[i]; i++) { + lfsr_rollback_word(unionstate.states + i, uid ^ nt, 0); + crypto1_get_lfsr(unionstate.states + i, &key_recovered); + unionstate.keylist[i] = key_recovered; } - keylist[i] = -1; + unionstate.keylist[i] = -1; - *keys = keylist; + *keys = unionstate.keylist; return i; } diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c index 8b57604f9..c3ad1b0a0 100644 --- a/client/src/mifare/mifarehost.c +++ b/client/src/mifare/mifarehost.c @@ -378,7 +378,7 @@ __attribute__((force_align_arg_pointer)) StateList_t *statelist = arg; statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt_enc ^ statelist->uid); - for (p1 = statelist->head.slhead; * (uint64_t *)p1 != 0; p1++) {}; + for (p1 = statelist->head.slhead; p1->odd | p1->even; p1++) {}; statelist->len = p1 - statelist->head.slhead; statelist->tail.sltail = --p1; @@ -492,8 +492,10 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, } } - *(uint64_t *)p3 = -1; - *(uint64_t *)p4 = -1; + p3->odd = -1; + p3->even = -1; + p4->odd = -1; + p4->even = -1; statelists[0].len = p3 - statelists[0].head.slhead; statelists[1].len = p4 - statelists[1].head.slhead; statelists[0].tail.sltail = --p3; @@ -637,7 +639,8 @@ int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBl } } - *(uint64_t *)p3 = -1; + p3->odd = -1; + p3->even = -1; statelists[0].len = p3 - statelists[0].head.slhead; statelists[0].tail.sltail = --p3; diff --git a/common/crc32.c b/common/crc32.c index 440bed910..b539baa05 100644 --- a/common/crc32.c +++ b/common/crc32.c @@ -23,8 +23,10 @@ void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc) { for (size_t i = 0; i < len; i++) { crc32_byte(&desfire_crc, data[i]); } - - *((uint32_t *)(crc)) = htole32(desfire_crc); + uint32_t crctmp = htole32(desfire_crc); + for (size_t i=0; i < sizeof(uint32_t); i++) { + crc[i] = ((uint8_t *) &crctmp)[i]; + } } void crc32_append(uint8_t *data, const size_t len) { diff --git a/common/mbedtls/Makefile b/common/mbedtls/Makefile index be5f08a0a..880f6bcc8 100644 --- a/common/mbedtls/Makefile +++ b/common/mbedtls/Makefile @@ -1,6 +1,6 @@ MYSRCPATHS = MYINCLUDES = -I. -I.. -MYCFLAGS = +MYCFLAGS = -Wno-cast-align MYDEFS = MYSRCS = \ aes.c \