diff --git a/client/cmdparser.c b/client/cmdparser.c index 77e2784ea..df068dd8d 100644 --- a/client/cmdparser.c +++ b/client/cmdparser.c @@ -37,10 +37,10 @@ int CmdsParse(const command_t Commands[], const char *Cmd) { dumpCommandsRecursive(Commands, 1); return 0; } - char cmd_name[64]; + char cmd_name[128]; int len = 0; memset(cmd_name, 0, sizeof(cmd_name)); - sscanf(Cmd, "%63s%n", cmd_name, &len); + sscanf(Cmd, "%127s%n", cmd_name, &len); str_lower(cmd_name); int i = 0; while (Commands[i].Name && strcmp(Commands[i].Name, cmd_name)) diff --git a/client/proxmark3.c b/client/proxmark3.c index c53049e4d..45fc1397e 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -59,7 +59,7 @@ void SendCommand(UsbCommand *c) { or disconnected. The main console thread is alive, but comm thread just spins here. Not good.../holiman **/ - while(txcmd_pending); + while (txcmd_pending); txcmd = *c; __atomic_test_and_set(&txcmd_pending, __ATOMIC_SEQ_CST); @@ -84,7 +84,7 @@ static void showBanner(void){ } #endif -static bool hookUpPM3() { +bool hookUpPM3() { bool ret = false; sp = uart_open( comport ); if (sp == INVALID_SERIAL_PORT) { @@ -104,7 +104,7 @@ static bool hookUpPM3() { } // (iceman) if uart_receiver fails a command three times, we conside the device to be offline. -static void *uart_receiver(void *targ) { +void *uart_receiver(void *targ) { struct receiver_arg *arg = (struct receiver_arg*)targ; size_t rxlen; bool tmpsignal; @@ -249,10 +249,11 @@ void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) { // execute command if (cmd) { - if (strlen(cmd) > 0) { - while(cmd[strlen(cmd) - 1] == ' ') - cmd[strlen(cmd) - 1] = 0x00; - } + + // rtrim + size_t l = strlen(cmd); + if ( l > 0 && isspace(cmd[l - 1])) + cmd[l-1] = 0x00; if (cmd[0] != 0x00) { int ret = CommandReceived(cmd); diff --git a/client/proxmark3.h b/client/proxmark3.h index 2afe018de..3a379066f 100644 --- a/client/proxmark3.h +++ b/client/proxmark3.h @@ -25,6 +25,9 @@ const char *get_my_executable_path(void); const char *get_my_executable_directory(void); void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present); +bool hookUpPM3(void); +void *uart_receiver(void *targ); + #ifdef __cplusplus } #endif diff --git a/client/scripting.c b/client/scripting.c index 27614784c..629497adf 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -20,7 +20,6 @@ static int l_SendCommand(lua_State *L){ /* - * The SendCommand (native) expects the following structure: typedef struct { @@ -34,11 +33,9 @@ static int l_SendCommand(lua_State *L){ ==> A 544 byte buffer will do. **/ - //Pop cmd size_t size; const char *data = luaL_checklstring(L, 1, &size); - if(size != sizeof(UsbCommand)) - { + if (size != sizeof(UsbCommand)) { printf("Got data size %d, expected %d" , (int) size,(int) sizeof(UsbCommand)); lua_pushstring(L,"Wrong data size"); return 1;