if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
memcpy(filename, Cmd+2, len);\r
\r
- FILE * f = fopen( filename , "r");\r
- \r
+ FILE * f = fopen( filename , "r"); \r
if ( !f ) {\r
PrintAndLog("File: %s: not found or locked.", filename);\r
free(keyBlock);\r
if (!p) {\r
PrintAndLog("Cannot allocate memory for defaultKeys");\r
free(keyBlock);\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 2;\r
}\r
keyBlock = p;\r
keycnt++;\r
memset(buf, 0, sizeof(buf));\r
} \r
- fclose(f);\r
- \r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
if (keycnt == 0) {\r
PrintAndLog("No keys found in file");\r
free(keyBlock);\r
// loop\r
uint64_t testpwd = 0x00;\r
for (uint16_t c = 0; c < keycnt; ++c ) {\r
- \r
+\r
+ if ( offline ) {\r
+ printf("Device offline\n");\r
+ free(keyBlock);\r
+ return 2;\r
+ }\r
+ \r
if (ukbhit()) {\r
ch = getchar();\r
(void)ch;\r
testpwd = bytes_to_num(keyBlock + 4*c, 4);\r
\r
PrintAndLog("Testing %08X", testpwd);\r
- \r
- \r
+ \r
if ( !AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, TRUE, testpwd)) {\r
PrintAndLog("Aquireing data from device failed. Quitting");\r
free(keyBlock);\r
}\r
\r
found = tryDetectModulation();\r
-\r
if ( found ) {\r
PrintAndLog("Found valid password: [%08X]", testpwd);\r
free(keyBlock);\r
\r
if (tryDetectModulation())\r
return 1;\r
- else return 0;\r
+ else \r
+ return 0;\r
}\r
\r
int CmdT55xxRecoverPW(const char *Cmd) {\r