Skip to content

Commit

Permalink
key: fix aes keys split not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodnorwell authored and Gamer64ytb committed Sep 22, 2024
1 parent f5bc85e commit 5cf9dc9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/hw/aes/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ std::vector<u8> HexToVector(const std::string& hex) {

std::optional<std::size_t> ParseCommonKeyName(const std::string& full_name) {
std::size_t index;
const char* start = full_name.c_str();
int end;
if (std::sscanf(full_name.c_str(), "common%zd%n", &index, &end) == 1 &&
end == static_cast<int>(full_name.size())) {
return index;
} else {
return std::nullopt;
if (std::sscanf(start, "common%zd%n", &index, &end) == 1) {
if (end == static_cast<int>(full_name.size()) || !std::isdigit(full_name[end])) {
return index;
}
}

return std::nullopt;
}

std::optional<std::pair<std::size_t, std::string>> ParseNfcSecretName(
Expand Down

0 comments on commit 5cf9dc9

Please sign in to comment.