Merge pull request #533 from merlokk/chktd

fix #532. looks at length of parameters.
This commit is contained in:
Iceman 2017-12-30 15:23:14 +01:00 committed by GitHub
commit e1e7a09db1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -987,6 +987,7 @@ int CmdHF14AMfChk(const char *Cmd)
int i, res; int i, res;
int keycnt = 0; int keycnt = 0;
char ctmp = 0x00; char ctmp = 0x00;
int clen = 0;
char ctmp3[3] = {0x00}; char ctmp3[3] = {0x00};
uint8_t blockNo = 0; uint8_t blockNo = 0;
uint8_t SectorsCnt = 0; uint8_t SectorsCnt = 0;
@ -1015,6 +1016,8 @@ int CmdHF14AMfChk(const char *Cmd)
blockNo = param_get8(Cmd, 0); blockNo = param_get8(Cmd, 0);
ctmp = param_getchar(Cmd, 1); ctmp = param_getchar(Cmd, 1);
clen = param_getlength(Cmd, 1);
if (clen == 1) {
switch (ctmp) { switch (ctmp) {
case 'a': case 'A': case 'a': case 'A':
keyType = 0; keyType = 0;
@ -1030,17 +1033,19 @@ int CmdHF14AMfChk(const char *Cmd)
free(keyBlock); free(keyBlock);
return 1; return 1;
}; };
}
// transfer to emulator & create dump file // transfer to emulator & create dump file
ctmp = param_getchar(Cmd, 2); ctmp = param_getchar(Cmd, 2);
if (ctmp == 't' || ctmp == 'T') transferToEml = 1; clen = param_getlength(Cmd, 2);
if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1; if (clen == 1 && (ctmp == 't' || ctmp == 'T')) transferToEml = 1;
if (clen == 1 && (ctmp == 'd' || ctmp == 'D')) createDumpFile = 1;
param3InUse = transferToEml | createDumpFile; param3InUse = transferToEml | createDumpFile;
timeout14a = 500; // fast by default timeout14a = 500; // fast by default
// double parameters - ts, ds // double parameters - ts, ds
int clen = param_getlength(Cmd, 2); clen = param_getlength(Cmd, 2);
if (clen == 2 || clen == 3){ if (clen == 2 || clen == 3){
param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3)); param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3));
ctmp = ctmp3[1]; ctmp = ctmp3[1];