Fix out-of-bounds access in three_parts. Fix mishandling of non-null terminated string_views in jwt_set::case_compare. Address several conversion and unreachability warnings

This commit is contained in:
Dennis Hezel 2022-05-13 19:13:38 +02:00
parent 0d662241da
commit 6c22d941a0
6 changed files with 11 additions and 33 deletions

View file

@ -70,7 +70,7 @@ inline void jwt_header::decode(const jwt::string_view enc_str, std::error_code&
try {
payload_ = json_t::parse(std::move(json_str));
} catch(const std::exception& e) {
} catch(const std::exception&) {
ec = DecodeErrc::JsonParseError;
return;
}
@ -130,7 +130,7 @@ inline void jwt_payload::decode(const jwt::string_view enc_str, std::error_code&
std::string json_str = base64_decode(enc_str);
try {
payload_ = json_t::parse(std::move(json_str));
} catch(const std::exception& e) {
} catch(const std::exception&) {
ec = DecodeErrc::JsonParseError;
return;
}
@ -530,7 +530,7 @@ jwt_object::three_parts(const jwt::string_view enc_str)
result[1] = jwt::string_view{&enc_str[fpos + 1], spos - fpos - 1};
if (spos != enc_str.length()) {
if (spos + 1 != enc_str.length()) {
result[2] = jwt::string_view{&enc_str[spos + 1], enc_str.length() - spos - 1};
}
@ -711,7 +711,7 @@ jwt_object decode(const jwt::string_view enc_str,
if (dparams.verify) {
try {
ec = obj.verify(dparams, algos);
} catch (const json_ns::detail::type_error& e) {
} catch (const json_ns::detail::type_error&) {
ec = VerificationErrc::TypeConversionError;
}