mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-25 03:40:35 +00:00
fix: add additional pin validation (#2007)
This commit is contained in:
parent
545af98459
commit
937d0d810c
@ -324,6 +324,7 @@ namespace nvhttp {
|
||||
tree.put("root.plaincert", util::hex_vec(conf_intern.servercert, true));
|
||||
tree.put("root.<xmlattr>.status_code", 200);
|
||||
}
|
||||
|
||||
void
|
||||
serverchallengeresp(pair_session_t &sess, pt::ptree &tree, const args_t &args) {
|
||||
auto encrypted_response = util::from_hex_vec(get_arg(args, "serverchallengeresp"), true);
|
||||
@ -573,6 +574,23 @@ namespace nvhttp {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure pin is 4 digits
|
||||
if (pin.size() != 4) {
|
||||
tree.put("root.paired", 0);
|
||||
tree.put("root.<xmlattr>.status_code", 400);
|
||||
tree.put(
|
||||
"root.<xmlattr>.status_message", "Pin must be 4 digits, " + std::to_string(pin.size()) + " provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure all pin characters are numeric
|
||||
if (!std::all_of(pin.begin(), pin.end(), ::isdigit)) {
|
||||
tree.put("root.paired", 0);
|
||||
tree.put("root.<xmlattr>.status_code", 400);
|
||||
tree.put("root.<xmlattr>.status_message", "Pin must be numeric");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &sess = std::begin(map_id_sess)->second;
|
||||
getservercert(sess, tree, pin);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user