-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fastheatup as percent-value, enlarge parse-buffer #122
- Loading branch information
1 parent
769301c
commit fcc2c0b
Showing
5 changed files
with
17 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ std::vector<Command::CmdFunction> Command::cmdfunctions_; | |
// returns 0 if the command errored, 1 (TRUE) if ok, 2 if not found, 3 if error or 4 if not allowed | ||
uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, bool authenticated, const int8_t id) { | ||
int8_t id_new = id; | ||
char cmd_new[20] = {'\0'}; | ||
strlcpy(cmd_new, cmd, 20); | ||
char cmd_new[30] = {'\0'}; | ||
strlcpy(cmd_new, cmd, sizeof(cmd_new)); | ||
|
||
// find the command | ||
auto cf = find_command(device_type, cmd_new, id_new); | ||
|
@@ -64,8 +64,8 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * | |
// returns 0 if the command errored, 1 (TRUE) if ok, 2 if not found, 3 if error or 4 if not allowed | ||
uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, bool authenticated, const int8_t id, JsonObject & json) { | ||
int8_t id_new = id; | ||
char cmd_new[20] = {'\0'}; | ||
strlcpy(cmd_new, cmd, 20); | ||
char cmd_new[30] = {'\0'}; | ||
strlcpy(cmd_new, cmd, sizeof(cmd_new)); | ||
|
||
auto cf = find_command(device_type, cmd_new, id_new); | ||
|
||
|
@@ -159,7 +159,7 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, char * c | |
|
||
// empty command after processing prefix is info | ||
if (cmd[0] == '\0') { | ||
strlcpy(cmd, "info", 20); | ||
strcpy(cmd, "info"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
MichaelDvP
Author
Contributor
|
||
} | ||
|
||
return find_command(device_type, cmd); | ||
|
@@ -209,7 +209,7 @@ Command::CmdFunction * Command::find_command(const uint8_t device_type, const ch | |
} | ||
|
||
// convert cmd to lowercase and compare | ||
char lowerCmd[20]; | ||
char lowerCmd[30]; | ||
strlcpy(lowerCmd, cmd, sizeof(lowerCmd)); | ||
for (char * p = lowerCmd; *p; p++) { | ||
*p = tolower(*p); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prefer strlcpy to be memory safe. can it be replaced using sizeof(cmd) ?