From 93585548844770b86a6482c936154413651f846f Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 3 May 2020 00:33:28 +0200 Subject: [PATCH] stricter warnings, wip --- client/Makefile | 3 +++ client/src/cmddata.c | 3 ++- client/src/cmdhf.c | 1 + client/src/cmdhf14a.c | 4 ++-- client/src/cmdhfmfdes.c | 26 +++++++++++++------------- client/src/cmdlf.c | 1 + client/src/cmdlfem4x.c | 1 + client/src/cmdlfindala.c | 1 + client/src/cmdlft55xx.c | 1 + client/src/cmdlfti.c | 1 + client/src/fileutils.c | 4 ++-- client/src/graph.c | 1 + client/src/loclass/cipherutils.h | 1 - client/src/ui.h | 10 ---------- client/src/util.h | 1 - common/generator.c | 4 ++-- common/generator.h | 5 +---- 17 files changed, 32 insertions(+), 36 deletions(-) diff --git a/client/Makefile b/client/Makefile index e8358757e..ed4e550ff 100644 --- a/client/Makefile +++ b/client/Makefile @@ -56,6 +56,9 @@ ZLIB = $(OBJDIR)/libz.a LIBS = -I$(LUALIBPATH) -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH) -I$(ZLIBPATH) -I$(REVENGPATH) -I$(AMIIBOLIBPATH) -I$(HARDNESTEDPATH) -I$(CLIPARSERPATH) INCLUDES_CLIENT += -I./src -I../include -I../common -I../common_fpga $(LIBS) CFLAGS ?= -Wall -Werror -O3 +#CFLAGS ?= -Wall -Werror -O3 -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wmissing-declarations +# -Wbad-function-cast -Wextra -Wswitch-enum -Wold-style-definition + # We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env: PM3CFLAGS = $(CFLAGS) $(INCLUDES_CLIENT) # WIP Testing diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 9a809f603..cf2256acb 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -18,6 +18,7 @@ #include "commonutil.h" // ARRAYLEN #include "cmdparser.h" // for command_t #include "ui.h" // for show graph controls +#include "proxgui.h" #include "graph.h" // for graph data #include "comms.h" #include "lfdemod.h" // for demod code @@ -287,7 +288,7 @@ static int usage_data_buffclear(void) { PrintAndLogEx(NORMAL, " h This help"); return PM3_SUCCESS; } -static int usage_data_fsktonrz() { +static int usage_data_fsktonrz(void) { PrintAndLogEx(NORMAL, "Usage: data fsktonrz c l f "); PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, " h This help"); diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index fbc99dbd5..ea5472c9d 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -37,6 +37,7 @@ #include "cmdhfcryptorf.h" // CryptoRF #include "cmdtrace.h" // trace list #include "ui.h" +#include "proxgui.h" #include "cmddata.h" #include "graph.h" #include "fpga.h" diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 262e879f4..7d2178c89 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1245,7 +1245,7 @@ int CmdHF14A(const char *Cmd) { return CmdsParse(CommandTable, Cmd); } -static void printTag(char *tag) { +static void printTag(const char *tag) { PrintAndLogEx(SUCCESS, "POSSIBLE TYPE:" _YELLOW_(" %s"), tag); } @@ -1340,7 +1340,7 @@ int detect_nxp_card(uint8_t sak, uint16_t atqa) { typedef struct { uint8_t uid0; uint8_t uid1; - char *desc; + const char *desc; } uidname; const uidname uidmap[] = { diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index b8c2271e1..c44bb4a3a 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -170,7 +170,7 @@ typedef enum { CL_AMISC7 = 0xFF, } aidcluster_h; -static char *cluster_to_text(uint8_t cluster) { +static const char *cluster_to_text(uint8_t cluster) { switch (cluster) { case CL_ADMIN: return "card administration"; @@ -375,7 +375,7 @@ static char *getVersionStr(uint8_t major, uint8_t minor) { } -int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t *result, int max_result_len, int *result_len, uint16_t *sw) { +static int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t *result, int max_result_len, int *result_len, uint16_t *sw) { *result_len = 0; if (sw) *sw = 0; @@ -433,7 +433,7 @@ int DESFIRESendApdu(bool activate_field, bool leavefield_on, sAPDU apdu, uint8_t return PM3_SUCCESS; } -static char *getstatus(uint16_t *sw) { +static const char *getstatus(uint16_t *sw) { if (sw == NULL) return "--> sw argument error. This should never happen !"; if (((*sw >> 8) & 0xFF) == 0x91) { switch (*sw & 0xFF) { @@ -500,7 +500,7 @@ static char *getstatus(uint16_t *sw) { return "Unknown error"; } -static char *GetErrorString(int res, uint16_t *sw) { +static const char *GetErrorString(int res, uint16_t *sw) { switch (res) { case PM3_EAPDU_FAIL: return getstatus(sw); @@ -642,7 +642,7 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) { return DESFIRE_UNKNOWN; } -int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload, bool defaultkey) { +static int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload, bool defaultkey) { // 3 different way to authenticate AUTH (CRC16) , AUTH_ISO (CRC32) , AUTH_AES (CRC32) // 4 different crypto arg1 DES, 3DES, 3K3DES, AES // 3 different communication modes, PLAIN,MAC,CRYPTO @@ -913,7 +913,7 @@ int handler_desfire_auth(mfdes_authinput_t *payload, mfdes_auth_res_t *rpayload, return PM3_SUCCESS; } -void AuthToError(int error) { +static void AuthToError(int error) { switch (error) { case 1: PrintAndLogEx(SUCCESS, "Sending auth command failed"); @@ -953,7 +953,7 @@ void AuthToError(int error) { } } // -- test if card supports 0x0A -static int test_desfire_authenticate() { +static int test_desfire_authenticate(void) { uint8_t data[] = {0x00}; sAPDU apdu = {0x90, MFDES_AUTHENTICATE, 0x00, 0x00, 0x01, data}; // 0x0A, KEY 0 int recv_len = 0; @@ -968,7 +968,7 @@ static int test_desfire_authenticate() { } // -- test if card supports 0x1A -static int test_desfire_authenticate_iso() { +static int test_desfire_authenticate_iso(void) { uint8_t data[] = {0x00}; sAPDU apdu = {0x90, MFDES_AUTHENTICATE_ISO, 0x00, 0x00, 0x01, data}; // 0x1A, KEY 0 int recv_len = 0; @@ -983,7 +983,7 @@ static int test_desfire_authenticate_iso() { } // -- test if card supports 0xAA -static int test_desfire_authenticate_aes() { +static int test_desfire_authenticate_aes(void) { uint8_t data[] = {0x00}; sAPDU apdu = {0x90, MFDES_AUTHENTICATE_AES, 0x00, 0x00, 0x01, data}; // 0xAA, KEY 0 int recv_len = 0; @@ -1210,7 +1210,7 @@ static int handler_desfire_keyversion(uint8_t curr_key, uint8_t *num_versions) { return res; } -static int handler_desfire_commit_transaction() { +static int handler_desfire_commit_transaction(void) { sAPDU apdu = {0x90, MFDES_COMMIT_TRANSACTION, 0x00, 0x00, 0x00, NULL}; //0xC7 int recv_len = 0; uint16_t sw = 0; @@ -1225,7 +1225,7 @@ static int handler_desfire_commit_transaction() { return res; } -/*static int handler_desfire_abort_transaction() { +/*static int handler_desfire_abort_transaction(void) { sAPDU apdu = {0x90, MFDES_ABORT_TRANSACTION, 0x00, 0x00, 0x00, NULL}; //0xA7 int recv_len = 0; uint16_t sw = 0; @@ -1647,7 +1647,7 @@ static int handler_desfire_create_backup_file(mfdes_file_t *file) { return res; } -int getKeySettings(uint8_t *aid) { +static int getKeySettings(uint8_t *aid) { if (aid == NULL) return PM3_EINVARG; int res = 0; @@ -3558,7 +3558,7 @@ static int CmdHF14ADesAuth(const char *Cmd) { return PM3_SUCCESS; } -void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t *aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t *k3kkeyListLen, uint32_t *startPattern) { +static void DesFill2bPattern(uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], size_t *deskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], size_t *aeskeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], size_t *k3kkeyListLen, uint32_t *startPattern) { for (uint32_t pt = *startPattern; pt < 0x10000; pt++) { if (*deskeyListLen != MAX_KEYS_LIST_LEN) { deskeyList[*deskeyListLen][0] = (pt >> 8) & 0xff; diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 9324062a1..a08ec2b9e 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -25,6 +25,7 @@ #include "lfdemod.h" // device/client demods of LF signals #include "ui.h" // for show graph controls +#include "proxgui.h" #include "graph.h" // for graph data #include "cmddata.h" // for `lf search` #include "cmdlfawid.h" // for awid menu diff --git a/client/src/cmdlfem4x.c b/client/src/cmdlfem4x.c index 734626700..f0e51b900 100644 --- a/client/src/cmdlfem4x.c +++ b/client/src/cmdlfem4x.c @@ -24,6 +24,7 @@ #include "util_posix.h" #include "protocols.h" #include "ui.h" +#include "proxgui.h" #include "graph.h" #include "cmddata.h" #include "cmdlf.h" diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 6cf5ed28f..7f3c4ee87 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -22,6 +22,7 @@ #include "cliparser.h" #include "commonutil.h" #include "ui.h" // PrintAndLog +#include "proxgui.h" #include "lfdemod.h" // parityTest, bitbytes_to_byte #include "cmddata.h" #include "cmdlf.h" // lf_read diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 5994e2232..09f2009bd 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -21,6 +21,7 @@ #include "comms.h" #include "commonutil.h" #include "protocols.h" +#include "proxgui.h" #include "graph.h" #include "cmddata.h" #include "lfdemod.h" diff --git a/client/src/cmdlfti.c b/client/src/cmdlfti.c index ed3b6f510..1c0dcbe1e 100644 --- a/client/src/cmdlfti.c +++ b/client/src/cmdlfti.c @@ -17,6 +17,7 @@ #include "comms.h" #include "crc16.h" #include "ui.h" +#include "proxgui.h" #include "graph.h" #include "cmdlfti.h" diff --git a/client/src/fileutils.c b/client/src/fileutils.c index b0b8d9772..4ccd4fa8f 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -1151,7 +1151,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key fclose(f); goto out; } else { - memset(*pdata + (mem_size - block_size), 0, block_size); + memset((uint8_t *)*pdata + (mem_size - block_size), 0, block_size); } } @@ -1171,7 +1171,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key uint64_t key = strtoull(line, NULL, 16); - num_to_bytes(key, keylen >> 1, *pdata + (*keycnt * (keylen >> 1))); + num_to_bytes(key, keylen >> 1, (uint8_t *)*pdata + (*keycnt * (keylen >> 1))); (*keycnt)++; diff --git a/client/src/graph.c b/client/src/graph.c index f9e610414..d5f62a6b7 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -11,6 +11,7 @@ #include #include #include "ui.h" +#include "proxgui.h" #include "util.h" //param_get32ex #include "lfdemod.h" #include "cmddata.h" //for g_debugmode diff --git a/client/src/loclass/cipherutils.h b/client/src/loclass/cipherutils.h index 6c90326a6..2e6e3dab9 100644 --- a/client/src/loclass/cipherutils.h +++ b/client/src/loclass/cipherutils.h @@ -61,7 +61,6 @@ void pushBit(BitstreamOut *stream, bool bit); int bitsLeft(BitstreamIn *stream); #ifndef ON_DEVICE int testCipherUtils(void); -int testMAC(void); #endif void push6bits(BitstreamOut *stream, uint8_t bits); void EncryptDES(bool key[56], bool outBlk[64], bool inBlk[64], int verbose) ; diff --git a/client/src/ui.h b/client/src/ui.h index e47031d70..ee101601e 100644 --- a/client/src/ui.h +++ b/client/src/ui.h @@ -48,22 +48,12 @@ extern session_arg_t session; #endif #define MAX_PRINT_BUFFER 2048 -void ShowGui(void); -void HideGraphWindow(void); -void ShowGraphWindow(void); -void RepaintGraphWindow(void); void PrintAndLogOptions(const char *str[][2], size_t size, size_t space); void PrintAndLogEx(logLevel_t level, const char *fmt, ...); void SetFlushAfterWrite(bool value); void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter); void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode); -extern double CursorScaleFactor; -extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset; -extern uint32_t CursorCPos, CursorDPos; -extern bool GridLocked; -extern bool showDemod; - int searchHomeFilePath(char **foundpath, const char *filename, bool create_home); extern pthread_mutex_t print_lock; diff --git a/client/src/util.h b/client/src/util.h index fb31e6013..59591ac24 100644 --- a/client/src/util.h +++ b/client/src/util.h @@ -87,7 +87,6 @@ void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length); void wiegand_add_parity_swapped(uint8_t *target, uint8_t *source, uint8_t length); //void xor(unsigned char *dst, unsigned char *src, size_t len); -int32_t le24toh(uint8_t data[3]); uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bits); uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor); diff --git a/common/generator.c b/common/generator.c index a456c6b78..653d57061 100644 --- a/common/generator.c +++ b/common/generator.c @@ -34,7 +34,7 @@ // XYZ 3D printing // Vinglock //------------------------------------ -void transform_D(uint8_t *ru) { +static void transform_D(uint8_t *ru) { const uint32_t c_D[] = { 0x6D835AFC, 0x7D15CD97, 0x0942B409, 0x32F9C923, 0xA811FB02, 0x64F121E8, @@ -415,7 +415,7 @@ int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys) { //------------------------------------ // Self tests //------------------------------------ -int generator_selftest() { +int generator_selftest(void) { #define NUM_OF_TEST 5 diff --git a/common/generator.h b/common/generator.h index d7ca2b8ee..c90fe483a 100644 --- a/common/generator.h +++ b/common/generator.h @@ -32,9 +32,6 @@ int mfc_algo_yale_all(uint8_t *uid, uint8_t *keys); int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys); -int mfc_algo_saflok_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); -int mfc_algo_saflok_all(uint8_t *uid, uint8_t *keys); - int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys); @@ -44,5 +41,5 @@ int mfc_algo_di_all(uint8_t *uid, uint8_t *keys); int mfc_algo_sky_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_sky_all(uint8_t *uid, uint8_t *keys); -int generator_selftest(); +int generator_selftest(void); #endif