diff --git a/client/emv/emv_pk.c b/client/emv/emv_pk.c index f78997f5a..a0bb80979 100644 --- a/client/emv/emv_pk.c +++ b/client/emv/emv_pk.c @@ -41,9 +41,13 @@ #define TOHEX(v) ((v) < 10 ? (v) + '0' : (v) - 10 + 'a') static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_t *read) { + + if ( buf == NULL ) + return 0; + size_t left = size; char *p = buf; - while (p != NULL && *p == ' ') + while (*p == ' ') p++; while (left > 0) { @@ -70,7 +74,7 @@ static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_ return -(p - buf); } - while (p != NULL && *p == ' ') + while (*p == ' ') p++; p--; @@ -79,13 +83,17 @@ static ssize_t emv_pk_read_bin(char *buf, unsigned char *bin, size_t size, size_ } static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) { + + if ( buf == NULL ) + return 0; + int i; unsigned char temp[3]; char *p = buf; *ymv = 0; - while (p != NULL && *p == ' ') + while (*p == ' ') p++; for (i = 0; i < 3; i++) { @@ -101,7 +109,7 @@ static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) { temp[i] = (c1 * 16 + c2); } - while (p != NULL && *p == ' ') + while (*p == ' ') p++; p--; @@ -115,8 +123,12 @@ static ssize_t emv_pk_read_ymv(char *buf, unsigned *ymv) { } static ssize_t emv_pk_read_string(char *buf, char *str, size_t size) { + + if ( buf == NULL ) + return 0; + char *p = buf; - while (p != NULL && *p == ' ') + while (*p == ' ') p++; while (size > 1) { @@ -132,7 +144,7 @@ static ssize_t emv_pk_read_string(char *buf, char *str, size_t size) { *str = 0; - while (p != NULL && *p == ' ') + while (*p == ' ') p++; p--; diff --git a/client/fpga_compress.c b/client/fpga_compress.c index 4cb45616b..aebb3d17d 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -42,7 +42,7 @@ #define COMPRESS_MAX_NICE_LENGTH 258 #define COMPRESS_MAX_CHAIN 8192 -#define HARDNESTED_TABLE_SIZE (sizeof(uint32_t) * ((1L<<19)+1)) +#define HARDNESTED_TABLE_SIZE (uint32_t)(sizeof(uint32_t) * ((1L<<19)+1)) static void usage(void) { fprintf(stdout, "Usage: fpga_compress ... \n"); @@ -95,15 +95,13 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn if (i >= num_infiles * (hardnested_mode ? HARDNESTED_TABLE_SIZE : FPGA_CONFIG_SIZE)) { if (hardnested_mode) { fprintf(stderr, -#if __WORDSIZE == 64 - "Input file too big (> %" PRIu64 " bytes). This is probably not a hardnested bitflip state table.\n" -#else - "Input file too big (> %li bytes). This is probably not a hardnested bitflip state table.\n" -#endif + "Input file too big (> %" PRIu32 " bytes). This is probably not a hardnested bitflip state table.\n" , HARDNESTED_TABLE_SIZE); } else { - fprintf(stderr, "Input files too big (total > %li bytes). These are probably not PM3 FPGA config files.\n", num_infiles * FPGA_CONFIG_SIZE); + fprintf(stderr, + "Input files too big (total > %li bytes). These are probably not PM3 FPGA config files.\n" + , num_infiles * FPGA_CONFIG_SIZE); } for (uint16_t j = 0; j < num_infiles; j++) { fclose(infile[j]);