make style
This commit is contained in:
@@ -70,13 +70,13 @@ json_t *AIDSearchGetElm(json_t *root, int elmindx) {
|
||||
}
|
||||
|
||||
int AIDSearchFree(json_t *root) {
|
||||
|
||||
|
||||
return closeAIDFile(root);
|
||||
}
|
||||
|
||||
const char * jsonStrGet(json_t *data, char *name) {
|
||||
const char *jsonStrGet(json_t *data, char *name) {
|
||||
json_t *jstr;
|
||||
|
||||
|
||||
jstr = json_object_get(data, name);
|
||||
if (jstr == NULL)
|
||||
return NULL;
|
||||
@@ -94,11 +94,11 @@ const char * jsonStrGet(json_t *data, char *name) {
|
||||
bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
||||
if (strcmp(aidlarge, aidsmall) == 0)
|
||||
return true;
|
||||
|
||||
|
||||
if (strlen(aidlarge) > strlen(aidsmall))
|
||||
if (strncmp(aidlarge, aidsmall, strlen(aidsmall)) == 0)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) {
|
||||
const char *hexaid = jsonStrGet(data, "AID");
|
||||
if (hexaid == NULL || strlen(hexaid) == 0)
|
||||
return false;
|
||||
|
||||
|
||||
int res = param_gethex_to_eol(hexaid, 0, aid, aidmaxlen, aidlen);
|
||||
if (res)
|
||||
return false;
|
||||
@@ -117,13 +117,13 @@ bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) {
|
||||
|
||||
int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
|
||||
json_t *root = xroot;
|
||||
if (root == NULL)
|
||||
root = AIDSearchInit(verbose);
|
||||
if (root == NULL)
|
||||
goto out;
|
||||
|
||||
|
||||
json_t *elm = NULL;
|
||||
int maxaidlen = 0;
|
||||
for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
||||
@@ -138,10 +138,10 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (elm == NULL)
|
||||
goto out;
|
||||
|
||||
|
||||
// print here
|
||||
const char *vaid = jsonStrGet(elm, "AID");
|
||||
const char *vendor = jsonStrGet(elm, "Vendor");
|
||||
@@ -167,7 +167,7 @@ int PrintAIDDescription(json_t *xroot, char *aid, bool verbose) {
|
||||
if (description)
|
||||
PrintAndLogEx(SUCCESS, "Description: %s", description);
|
||||
}
|
||||
|
||||
|
||||
out:
|
||||
if (xroot == NULL)
|
||||
AIDSearchFree(root);
|
||||
|
||||
@@ -2753,33 +2753,33 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) {
|
||||
|
||||
//
|
||||
// MFU TearOff against OTP
|
||||
// Mobeius et al
|
||||
// Moebius et al
|
||||
//
|
||||
static int CmdHF14AMfuOtpTearoff(const char *Cmd){
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = 0;
|
||||
uint32_t len = strtol(Cmd, NULL, 0);
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_hf_mfu_otp_tearoff();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = 0;
|
||||
uint32_t len = strtol(Cmd, NULL, 0);
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||
|
||||
if (errors) return usage_hf_mfu_otp_tearoff();
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h':
|
||||
return usage_hf_mfu_otp_tearoff();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MFU_OTP_TEAROFF, data, len);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "Failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
if (errors) return usage_hf_mfu_otp_tearoff();
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MFU_OTP_TEAROFF, data, len);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "Failed");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//------------------------------------
|
||||
|
||||
@@ -121,7 +121,7 @@ static int CmdJablotronDemod(const char *Cmd) {
|
||||
uint8_t chksum = raw2 & 0xFF;
|
||||
bool isok = (chksum == jablontron_chksum(DemodBuffer));
|
||||
|
||||
PrintAndLogEx( isok ? SUCCESS : INFO,
|
||||
PrintAndLogEx(isok ? SUCCESS : INFO,
|
||||
"Checksum: %02X [ %s]",
|
||||
chksum,
|
||||
isok ? _GREEN_("OK") : _RED_("Fail")
|
||||
|
||||
@@ -314,44 +314,44 @@ static int l_GetFromFlashMemSpiffs(lua_State *L) {
|
||||
|
||||
if (IfPm3Flash()) {
|
||||
uint32_t start_index = 0, len = 0x40000; //FLASH_MEM_MAX_SIZE
|
||||
char destfilename[32] = {0};
|
||||
size_t size;
|
||||
char destfilename[32] = {0};
|
||||
size_t size;
|
||||
|
||||
int n = lua_gettop(L);
|
||||
if (n == 0)
|
||||
return returnToLuaWithError(L, "You need to supply the destination filename");
|
||||
|
||||
if (n >= 1) {
|
||||
const char *p_filename = luaL_checklstring(L, 1, &size);
|
||||
if (size != 0)
|
||||
memcpy(destfilename, p_filename, 31);
|
||||
}
|
||||
|
||||
if (destfilename[0] == '\0')
|
||||
return returnToLuaWithError(L, "Filename missing or invalid");
|
||||
|
||||
// get size from spiffs itself !
|
||||
SendCommandMIX(CMD_SPIFFS_STAT, 0, 0, 0, (uint8_t *)destfilename, 32);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000))
|
||||
return returnToLuaWithError(L, "No response from the device");
|
||||
const char *p_filename = luaL_checklstring(L, 1, &size);
|
||||
if (size != 0)
|
||||
memcpy(destfilename, p_filename, 31);
|
||||
}
|
||||
|
||||
if (destfilename[0] == '\0')
|
||||
return returnToLuaWithError(L, "Filename missing or invalid");
|
||||
|
||||
// get size from spiffs itself !
|
||||
SendCommandMIX(CMD_SPIFFS_STAT, 0, 0, 0, (uint8_t *)destfilename, 32);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000))
|
||||
return returnToLuaWithError(L, "No response from the device");
|
||||
|
||||
len = resp.oldarg[0];
|
||||
|
||||
len = resp.oldarg[0];
|
||||
|
||||
if (len <= 0)
|
||||
return returnToLuaWithError(L, "Filename invalid or empty");
|
||||
|
||||
|
||||
uint8_t *data = calloc(len, sizeof(uint8_t));
|
||||
if (!data)
|
||||
return returnToLuaWithError(L, "Allocating memory failed");
|
||||
|
||||
if (!GetFromDevice(SPIFFS, data, len, start_index, (uint8_t *)destfilename, 32, NULL, -1, true)) {
|
||||
free(data);
|
||||
return returnToLuaWithError(L, "ERROR; downloading from spiffs(flashmemory)");
|
||||
}
|
||||
if (!GetFromDevice(SPIFFS, data, len, start_index, (uint8_t *)destfilename, 32, NULL, -1, true)) {
|
||||
free(data);
|
||||
return returnToLuaWithError(L, "ERROR; downloading from spiffs(flashmemory)");
|
||||
}
|
||||
|
||||
lua_pushlstring(L, (const char *)data, len);
|
||||
lua_pushunsigned(L, len);
|
||||
lua_pushunsigned(L, len);
|
||||
free(data);
|
||||
return 2;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user