fix a few cppcheck warnings
This commit is contained in:
1 parent
d97f417ee6
commit
3aeb5c493f
13 files changed
+44
-41
No files matched your search
@@ -2224,7 +2224,7 @@ int CmdNorm(const char *Cmd) {
|
||||
if (g_GraphBuffer[i] < min) min = g_GraphBuffer[i];
|
||||
}
|
||||
|
||||
if (max != min) {
|
||||
if ((g_GraphTraceLen > 10) && (max != min)) {
|
||||
for (uint32_t i = 0; i < g_GraphTraceLen; ++i) {
|
||||
g_GraphBuffer[i] = ((long)(g_GraphBuffer[i] - ((max + min) / 2)) * 256) / (max - min);
|
||||
//marshmelow: adjusted *1000 to *256 to make +/- 128 so demod commands still work
|
||||
@@ -3218,12 +3218,12 @@ static int CmdNumCon(const char *Cmd) {
|
||||
int hlen = 256;
|
||||
char hex[256];
|
||||
memset(hex, 0, sizeof(hex));
|
||||
res = CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)hex, sizeof(hex), &hlen);
|
||||
res |= CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)hex, sizeof(hex), &hlen);
|
||||
|
||||
int blen = 256;
|
||||
char bin[256];
|
||||
memset(bin, 0, sizeof(bin));
|
||||
res = CLIParamStrToBuf(arg_get_str(ctx, 3), (uint8_t *)bin, sizeof(bin), &blen);
|
||||
res |= CLIParamStrToBuf(arg_get_str(ctx, 3), (uint8_t *)bin, sizeof(bin), &blen);
|
||||
|
||||
bool shall_invert = arg_get_lit(ctx, 4);
|
||||
CLIParserFree(ctx);
|
||||
@@ -3236,6 +3236,7 @@ static int CmdNumCon(const char *Cmd) {
|
||||
|
||||
// results for MPI actions
|
||||
bool ret = false;
|
||||
(void) ret;
|
||||
|
||||
// container of big number
|
||||
mbedtls_mpi N;
|
||||
|
||||
@@ -1362,8 +1362,8 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
|
||||
if (data_size > 2) {
|
||||
uint16_t uBlockNum = MemLeToUint2byte(data) ;
|
||||
uint8_t uQty = data[2] ;
|
||||
if (uQty != 1) {
|
||||
snprintf(exp, size, "READ %s(%u-%u) %s_%s", encrypted, uBlockNum, uBlockNum + uQty - 1, responseMaced, commandMaced);
|
||||
if (uQty > 1) {
|
||||
snprintf(exp, size, "READ %s(%u-%i) %s_%s", encrypted, uBlockNum, uBlockNum + uQty - 1, responseMaced, commandMaced);
|
||||
} else {
|
||||
snprintf(exp, size, "READ %s(%u) %s_%s", encrypted, uBlockNum, responseMaced, commandMaced);
|
||||
}
|
||||
|
||||
+13
-13
@@ -28,8 +28,8 @@
|
||||
#include "util.h"
|
||||
#include "util_posix.h"
|
||||
#include "iso7816/iso7816core.h"
|
||||
#include "stddef.h"
|
||||
#include "stdbool.h"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "mifare.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -59,10 +59,10 @@ uint8_t aid[] = { 0x4f, 0x53, 0x45, 0x2e, 0x56, 0x41, 0x53, 0x2e, 0x30, 0x31 };
|
||||
uint8_t getVasUrlOnlyP2 = 0x00;
|
||||
uint8_t getVasFullReqP2 = 0x01;
|
||||
|
||||
static int ParseSelectVASResponse(uint8_t *response, size_t resLen, bool verbose) {
|
||||
static int ParseSelectVASResponse(const uint8_t *response, size_t resLen, bool verbose) {
|
||||
struct tlvdb *tlvRoot = tlvdb_parse_multi(response, resLen);
|
||||
|
||||
struct tlvdb *versionTlv = tlvdb_find_full(tlvRoot, 0x9F21);
|
||||
const struct tlvdb *versionTlv = tlvdb_find_full(tlvRoot, 0x9F21);
|
||||
if (versionTlv == NULL) {
|
||||
tlvdb_free(tlvRoot);
|
||||
return PM3_ECARDEXCHANGE;
|
||||
@@ -80,7 +80,7 @@ static int ParseSelectVASResponse(uint8_t *response, size_t resLen, bool verbose
|
||||
return PM3_ECARDEXCHANGE;
|
||||
}
|
||||
|
||||
struct tlvdb *capabilitiesTlv = tlvdb_find_full(tlvRoot, 0x9F23);
|
||||
const struct tlvdb *capabilitiesTlv = tlvdb_find_full(tlvRoot, 0x9F23);
|
||||
if (capabilitiesTlv == NULL) {
|
||||
tlvdb_free(tlvRoot);
|
||||
return PM3_ECARDEXCHANGE;
|
||||
@@ -99,7 +99,7 @@ static int ParseSelectVASResponse(uint8_t *response, size_t resLen, bool verbose
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CreateGetVASDataCommand(uint8_t *pidHash, const char *url, size_t urlLen, uint8_t *out, int *outLen) {
|
||||
static int CreateGetVASDataCommand(const uint8_t *pidHash, const char *url, size_t urlLen, uint8_t *out, int *outLen) {
|
||||
if (pidHash == NULL && url == NULL) {
|
||||
PrintAndLogEx(FAILED, "Must provide a Pass Type ID or a URL");
|
||||
return PM3_EINVARG;
|
||||
@@ -154,10 +154,10 @@ static int CreateGetVASDataCommand(uint8_t *pidHash, const char *url, size_t url
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int ParseGetVASDataResponse(uint8_t *res, size_t resLen, uint8_t *cryptogram, size_t *cryptogramLen) {
|
||||
static int ParseGetVASDataResponse(const uint8_t *res, size_t resLen, uint8_t *cryptogram, size_t *cryptogramLen) {
|
||||
struct tlvdb *tlvRoot = tlvdb_parse_multi(res, resLen);
|
||||
|
||||
struct tlvdb *cryptogramTlvdb = tlvdb_find_full(tlvRoot, 0x9F27);
|
||||
const struct tlvdb *cryptogramTlvdb = tlvdb_find_full(tlvRoot, 0x9F27);
|
||||
if (cryptogramTlvdb == NULL) {
|
||||
tlvdb_free(tlvRoot);
|
||||
return PM3_ECARDEXCHANGE;
|
||||
@@ -171,10 +171,10 @@ static int ParseGetVASDataResponse(uint8_t *res, size_t resLen, uint8_t *cryptog
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int LoadReaderPrivateKey(uint8_t *buf, size_t bufLen, mbedtls_ecp_keypair *privKey) {
|
||||
static int LoadReaderPrivateKey(const uint8_t *buf, size_t bufLen, mbedtls_ecp_keypair *privKey) {
|
||||
struct tlvdb *derRoot = tlvdb_parse_multi(buf, bufLen);
|
||||
|
||||
struct tlvdb *privkeyTlvdb = tlvdb_find_full(derRoot, 0x04);
|
||||
const struct tlvdb *privkeyTlvdb = tlvdb_find_full(derRoot, 0x04);
|
||||
if (privkeyTlvdb == NULL) {
|
||||
tlvdb_free(derRoot);
|
||||
return PM3_EINVARG;
|
||||
@@ -187,7 +187,7 @@ static int LoadReaderPrivateKey(uint8_t *buf, size_t bufLen, mbedtls_ecp_keypair
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
struct tlvdb *pubkeyCoordsTlvdb = tlvdb_find_full(derRoot, 0x03);
|
||||
const struct tlvdb *pubkeyCoordsTlvdb = tlvdb_find_full(derRoot, 0x03);
|
||||
if (pubkeyCoordsTlvdb == NULL) {
|
||||
tlvdb_free(derRoot);
|
||||
PrintAndLogEx(FAILED, "Private key file should include public key component");
|
||||
@@ -229,7 +229,7 @@ static int GetPrivateKeyHint(mbedtls_ecp_keypair *privKey, uint8_t *keyHint) {
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int LoadMobileEphemeralKey(uint8_t *xcoordBuf, mbedtls_ecp_keypair *pubKey) {
|
||||
static int LoadMobileEphemeralKey(const uint8_t *xcoordBuf, mbedtls_ecp_keypair *pubKey) {
|
||||
uint8_t compressedEcKey[33] = {0};
|
||||
compressedEcKey[0] = 0x02;
|
||||
memcpy(compressedEcKey + 1, xcoordBuf, 32);
|
||||
@@ -249,7 +249,7 @@ static int LoadMobileEphemeralKey(uint8_t *xcoordBuf, mbedtls_ecp_keypair *pubKe
|
||||
|
||||
static int internalVasDecrypt(uint8_t *cipherText, size_t cipherTextLen, uint8_t *sharedSecret,
|
||||
uint8_t *ansiSharedInfo, size_t ansiSharedInfoLen,
|
||||
uint8_t *gcmAad, size_t gcmAadLen, uint8_t *out, size_t *outLen) {
|
||||
const uint8_t *gcmAad, size_t gcmAadLen, uint8_t *out, size_t *outLen) {
|
||||
uint8_t key[32] = {0};
|
||||
if (ansi_x963_sha256(sharedSecret, 32, ansiSharedInfo, ansiSharedInfoLen, sizeof(key), key)) {
|
||||
PrintAndLogEx(FAILED, "ANSI X9.63 key derivation failed");
|
||||
|
||||
@@ -2646,7 +2646,7 @@ static int CmdEMVReader(const char *Cmd) {
|
||||
res = EMVSelectPSE(channel, true, true, 2, buf, sizeof(buf), &len, &sw);
|
||||
|
||||
// search PSE / PPSE
|
||||
res = EMVSearchPSE(channel, false, true, psenum, false, tlvSelect);
|
||||
res |= EMVSearchPSE(channel, false, true, psenum, false, tlvSelect);
|
||||
if (res) {
|
||||
// EMV SEARCH with AID list
|
||||
DropFieldEx(channel);
|
||||
|
||||
@@ -606,7 +606,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
||||
}
|
||||
}
|
||||
|
||||
static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[FLASH_MAX_FILES], bool can_write_bl, bool force) {
|
||||
static int flash_pm3(char *serial_port_name, uint8_t num_files, const char *filenames[FLASH_MAX_FILES], bool can_write_bl, bool force) {
|
||||
|
||||
int ret = PM3_EUNDEF;
|
||||
flash_file_t files[FLASH_MAX_FILES];
|
||||
@@ -756,7 +756,7 @@ int main(int argc, char *argv[]) {
|
||||
bool flash_force = false;
|
||||
bool debug_mode_forced = false;
|
||||
int flash_num_files = 0;
|
||||
char *flash_filenames[FLASH_MAX_FILES];
|
||||
const char *flash_filenames[FLASH_MAX_FILES];
|
||||
|
||||
// color management:
|
||||
// 1. default = no color
|
||||
|
||||
Reference in new issue
Block a user