Skip to content

Commit

Permalink
Fix not writing to entire CMD_t data field from UART
Browse files Browse the repository at this point in the history
  • Loading branch information
liquiddandruff committed Jun 10, 2018
1 parent 9d1e8f6 commit db957df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SFUsat/sfu_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ int8_t checkAndRunCommandStr(char *cmd) {
if (data != NULL) {
const int data_len = strlen(data);
unsigned int i = 0;
for (i = 0; i < CMD_DATA_MAX_SIZE * 2 && i < data_len; i += 2) {
for (i = 0; i < sizeof(cmd_t.cmd_data) * 2 && i < data_len; i += 2) {
char c[3] = {NULL};
c[0] = *(data + i);
// TODO: fix dereference beyond null char
Expand All @@ -700,7 +700,7 @@ int8_t checkAndRunCommandStr(char *cmd) {
}
int ret = sprintf(buffer, "cmd_data set to: 0x");
i = 0;
for (i = 0; i < data_len && i < CMD_DATA_MAX_SIZE; i++) {
for (i = 0; i < data_len && i < sizeof(cmd_t.cmd_data); i++) {
ret += snprintf(buffer + ret, sizeof(buffer), "%02x", cmd_t.cmd_data[i]);
}
serialSend(buffer);
Expand Down

0 comments on commit db957df

Please sign in to comment.