Skip to content

Commit

Permalink
stricted scancode config syntax checking
Browse files Browse the repository at this point in the history
  • Loading branch information
y5nw committed Sep 3, 2024
1 parent d3710e2 commit a266076
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/client/keycode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,14 @@ wchar_t KeyPress::getKeychar() const

bool KeyPress::loadFromScancode(std::string_view name)
{
if (name.size() < 2 || name[0] != '<')
if (name.size() < 2 || name[0] != '<' || name.back() != '>')
return false;
char *p;
scancode = strtoul(name.data()+1, &p, 10);
return p > name.data()+1;
const auto code = strtoul(name.data()+1, &p, 10);
if (p != name.data() + name.size() - 1)
return false;
scancode = code;
return true;
}

std::unordered_map<std::string, KeyPress> KeyPress::specialKeyCache;
Expand Down

0 comments on commit a266076

Please sign in to comment.