Skip to content

Commit

Permalink
Add some verification for the wled commands to prevent a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Dec 4, 2024
1 parent 5d23f0b commit ec480f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/commands/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,9 @@ HTTP_RESPONSE_CONST std::shared_ptr<httpserver::http_response> CommandManager::r
}
}
} else {
Json::Value val = LoadJsonFromString(std::string(req.get_content()));
std::string command(req.get_content());
LogDebug(VB_COMMAND, "Received command: \"%s\"\n", command.c_str());
Json::Value val = LoadJsonFromString(command);
std::unique_ptr<Command::Result> r = run(val);
int count = 0;
while (!r->isDone() && count < 1000) {
Expand Down
6 changes: 5 additions & 1 deletion src/overlays/WLEDEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ class RawWLEDEffect : public WLEDEffect {

int mapping = 0;
bool hasC3 = false;
for (int x = 0; x < argMap.size(); x++) {
int count = args.size();
if (count > argMap.size()) {
count = argMap.size();
}
for (int x = 0; x < count; x++) {
switch (argMap[x]) {
case ArgMapping::Mapping:
mapping = std::find(BUFFERMAPS->begin(), BUFFERMAPS->end(), args[x]) - BUFFERMAPS->begin();
Expand Down

0 comments on commit ec480f0

Please sign in to comment.