]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/mifarehost.c
CHG: moved to header file
[proxmark3-svn] / client / mifarehost.c
index b41c368702e6cbb4c94e82ee519ff9f2b5e7c8f5..f9e058071437f05a96dae18a360cd15405b409d6 100644 (file)
@@ -250,15 +250,13 @@ int mfKeyBrute(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint64_t *resultk
        return found;\r
 }\r
 \r
-\r
 // EMULATOR\r
-\r
 int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount) {\r
        UsbCommand c = {CMD_MIFARE_EML_MEMGET, {blockNum, blocksCount, 0}};\r
        clearCommandBuffer();\r
        SendCommand(&c);\r
        UsbCommand resp;\r
-       if (!WaitForResponseTimeout(CMD_ACK,&resp,1500)) return 1;\r
+       if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 1;\r
        memcpy(data, resp.d.asBytes, blocksCount * 16);\r
        return 0;\r
 }\r
@@ -412,14 +410,20 @@ int loadTraceCard(uint8_t *tuid, uint8_t uidlen) {
                memset(buf, 0, sizeof(buf));\r
                if (fgets(buf, sizeof(buf), f) == NULL) {\r
                        PrintAndLog("No trace file found or reading error.");\r
-                       fclose(f);\r
+                       if (f) {\r
+                               fclose(f);\r
+                               f = NULL;\r
+                       }\r
                        return 2;\r
                }\r
 \r
                if (strlen(buf) < 32){\r
                        if (feof(f)) break;\r
                        PrintAndLog("File content error. Block data must include 32 HEX symbols");\r
-                       fclose(f);\r
+                       if (f) {\r
+                               fclose(f);\r
+                               f = NULL;\r
+                       }\r
                        return 2;\r
                }\r
                for (i = 0; i < 32; i += 2)\r
@@ -429,7 +433,10 @@ int loadTraceCard(uint8_t *tuid, uint8_t uidlen) {
 \r
                blockNum++;\r
        }\r
-       fclose(f);\r
+       if (f) {\r
+               fclose(f);\r
+               f = NULL;\r
+       }\r
        return 0;\r
 }\r
 \r
@@ -447,7 +454,10 @@ int saveTraceCard(void) {
                fprintf(f,"\n");\r
        }\r
        fflush(f);\r
-       fclose(f);\r
+       if (f) {\r
+               fclose(f);\r
+               f = NULL;\r
+       }\r
        return 0;\r
 }\r
 \r
Impressum, Datenschutz