Fixed error pointed out here: https://code.google.com/p/proxmark3/issues/detail?id=46, when null is passed to waitforresponse

This commit is contained in:
martin.holst@gmail.com 2013-06-03 11:04:35 +00:00
commit ab7a8ea164

View file

@ -26,9 +26,9 @@
#include "util.h" #include "util.h"
unsigned int current_command = CMD_UNKNOWN; unsigned int current_command = CMD_UNKNOWN;
unsigned int received_command = CMD_UNKNOWN; //unsigned int received_command = CMD_UNKNOWN;
UsbCommand current_response; //UsbCommand current_response;
UsbCommand current_response_user; //UsbCommand current_response_user;
static int CmdHelp(const char *Cmd); static int CmdHelp(const char *Cmd);
static int CmdQuit(const char *Cmd); static int CmdQuit(const char *Cmd);
@ -74,6 +74,11 @@ int CmdQuit(const char *Cmd)
* @return true if command was returned, otherwise false * @return true if command was returned, otherwise false
*/ */
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout) { bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout) {
if (response == NULL) {
UsbCommand resp;
response = &resp;
}
// Wait until the command is received // Wait until the command is received
for(size_t dm_seconds=0; dm_seconds < ms_timeout/10; dm_seconds++) { for(size_t dm_seconds=0; dm_seconds < ms_timeout/10; dm_seconds++) {
@ -175,6 +180,7 @@ void UsbCommandReceived(UsbCommand *UC)
default: { default: {
// Maybe it's a response // Maybe it's a response
/*
switch(current_command) { switch(current_command) {
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: { case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: {
if (UC->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { if (UC->cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {
@ -186,13 +192,14 @@ void UsbCommandReceived(UsbCommand *UC)
memcpy(sample_buf+UC->arg[0],UC->d.asBytes,48); memcpy(sample_buf+UC->arg[0],UC->d.asBytes,48);
sample_buf_len += 48; sample_buf_len += 48;
// for(i=0; i<48; i++) sample_buf[i] = UC->d.asBytes[i]; // for(i=0; i<48; i++) sample_buf[i] = UC->d.asBytes[i];
received_command = UC->cmd; //received_command = UC->cmd;
} break; } break;
default: { default: {
} break; } break;
} }*/
} break; }
break;
} }
storeCommand(UC); storeCommand(UC);