Skip to content

Commit

Permalink
Add safe addition in decoder.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag committed Mar 6, 2024
1 parent 4077045 commit b55e778
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kuksa_databroker/databroker/src/authorization/jwt/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ impl TryFrom<Claims> for Permissions {
}
}

permissions = permissions
.expires_at(std::time::UNIX_EPOCH + std::time::Duration::from_secs(claims.exp));
if let Some(expire_date) =
std::time::UNIX_EPOCH.checked_add(std::time::Duration::from_secs(claims.exp))
{
permissions = permissions.expires_at(expire_date);
} else {
return Err(Error::ClaimsError);
}

permissions.build().map_err(|err| match err {
PermissionsBuildError::BuildError => Error::ClaimsError,
Expand Down

0 comments on commit b55e778

Please sign in to comment.