fix bug in pskdemod return value if no samples...

... caused crash in data psknexwatchdemod if no samples were in the
graphbuffer.
also fixed hf mfu wrbl and rdbl to allow printing of help without a tag
being present.
This commit is contained in:
marshmellow42 2015-06-23 12:16:23 -04:00
parent 7c8b5e6811
commit 2ec8773314
2 changed files with 28 additions and 32 deletions

View file

@ -1546,12 +1546,12 @@ int PSKDemod(const char *Cmd, bool verbose)
clk=0; clk=0;
} }
if (invert != 0 && invert != 1) { if (invert != 0 && invert != 1) {
if (verbose) PrintAndLog("Invalid argument: %s", Cmd); if (g_debugMode || verbose) PrintAndLog("Invalid argument: %s", Cmd);
return 0; return 0;
} }
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0}; uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
size_t BitLen = getFromGraphBuf(BitStream); size_t BitLen = getFromGraphBuf(BitStream);
if (BitLen==0) return -1; if (BitLen==0) return 0;
uint8_t carrier=countFC(BitStream, BitLen, 0); uint8_t carrier=countFC(BitStream, BitLen, 0);
if (carrier!=2 && carrier!=4 && carrier!=8){ if (carrier!=2 && carrier!=4 && carrier!=8){
//invalid carrier //invalid carrier

View file

@ -908,10 +908,6 @@ int CmdHF14AMfUWrBl(const char *Cmd){
uint8_t authenticationkey[16] = {0x00}; uint8_t authenticationkey[16] = {0x00};
uint8_t *authKeyPtr = authenticationkey; uint8_t *authKeyPtr = authenticationkey;
// starting with getting tagtype
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
while(param_getchar(Cmd, cmdp) != 0x00) while(param_getchar(Cmd, cmdp) != 0x00)
{ {
switch(param_getchar(Cmd, cmdp)) switch(param_getchar(Cmd, cmdp))
@ -943,21 +939,10 @@ int CmdHF14AMfUWrBl(const char *Cmd){
case 'b': case 'b':
case 'B': case 'B':
blockNo = param_get8(Cmd, cmdp+1); blockNo = param_get8(Cmd, cmdp+1);
uint8_t maxblockno = 0;
for (uint8_t idx = 0; idx < MAX_UL_TYPES; idx++){
if (tagtype & UL_TYPES_ARRAY[idx])
maxblockno = UL_MEMORY_ARRAY[idx];
}
if (blockNo < 0) { if (blockNo < 0) {
PrintAndLog("Wrong block number"); PrintAndLog("Wrong block number");
errors = true; errors = true;
} }
if (blockNo > maxblockno){
PrintAndLog("block number too large. Max block is %u/0x%02X \n", maxblockno,maxblockno);
errors = true;
}
cmdp += 2; cmdp += 2;
break; break;
case 'l': case 'l':
@ -984,6 +969,19 @@ int CmdHF14AMfUWrBl(const char *Cmd){
} }
if ( blockNo == -1 ) return usage_hf_mfu_wrbl(); if ( blockNo == -1 ) return usage_hf_mfu_wrbl();
// starting with getting tagtype
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
uint8_t maxblockno = 0;
for (uint8_t idx = 0; idx < MAX_UL_TYPES; idx++){
if (tagtype & UL_TYPES_ARRAY[idx])
maxblockno = UL_MEMORY_ARRAY[idx];
}
if (blockNo > maxblockno){
PrintAndLog("block number too large. Max block is %u/0x%02X \n", maxblockno,maxblockno);
return usage_hf_mfu_wrbl();
}
// Swap endianness // Swap endianness
if (swapEndian && hasAuthKey) authKeyPtr = SwapEndian64(authenticationkey, 16, 8); if (swapEndian && hasAuthKey) authKeyPtr = SwapEndian64(authenticationkey, 16, 8);
@ -1035,10 +1033,6 @@ int CmdHF14AMfURdBl(const char *Cmd){
uint8_t authenticationkey[16] = {0x00}; uint8_t authenticationkey[16] = {0x00};
uint8_t *authKeyPtr = authenticationkey; uint8_t *authKeyPtr = authenticationkey;
// starting with getting tagtype
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
while(param_getchar(Cmd, cmdp) != 0x00) while(param_getchar(Cmd, cmdp) != 0x00)
{ {
switch(param_getchar(Cmd, cmdp)) switch(param_getchar(Cmd, cmdp))
@ -1070,21 +1064,10 @@ int CmdHF14AMfURdBl(const char *Cmd){
case 'b': case 'b':
case 'B': case 'B':
blockNo = param_get8(Cmd, cmdp+1); blockNo = param_get8(Cmd, cmdp+1);
uint8_t maxblockno = 0;
for (uint8_t idx = 0; idx < MAX_UL_TYPES; idx++){
if (tagtype & UL_TYPES_ARRAY[idx])
maxblockno = UL_MEMORY_ARRAY[idx];
}
if (blockNo < 0) { if (blockNo < 0) {
PrintAndLog("Wrong block number"); PrintAndLog("Wrong block number");
errors = true; errors = true;
} }
if (blockNo > maxblockno){
PrintAndLog("block number to large. Max block is %u/0x%02X \n", maxblockno,maxblockno);
errors = true;
}
cmdp += 2; cmdp += 2;
break; break;
case 'l': case 'l':
@ -1102,6 +1085,19 @@ int CmdHF14AMfURdBl(const char *Cmd){
} }
if ( blockNo == -1 ) return usage_hf_mfu_rdbl(); if ( blockNo == -1 ) return usage_hf_mfu_rdbl();
// start with getting tagtype
TagTypeUL_t tagtype = GetHF14AMfU_Type();
if (tagtype == UL_ERROR) return -1;
uint8_t maxblockno = 0;
for (uint8_t idx = 0; idx < MAX_UL_TYPES; idx++){
if (tagtype & UL_TYPES_ARRAY[idx])
maxblockno = UL_MEMORY_ARRAY[idx];
}
if (blockNo > maxblockno){
PrintAndLog("block number to large. Max block is %u/0x%02X \n", maxblockno,maxblockno);
return usage_hf_mfu_rdbl();
}
// Swap endianness // Swap endianness
if (swapEndian && hasAuthKey) authKeyPtr = SwapEndian64(authenticationkey, 16, 8); if (swapEndian && hasAuthKey) authKeyPtr = SwapEndian64(authenticationkey, 16, 8);