Skip to content

Commit 215b8ca

Browse files
djw8605Copilot
andauthored
Use floor during the double cast
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent af41322 commit 215b8ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/scitokens.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ int scitoken_get_expiration(const SciToken token, long long *expiry,
244244
result = claim_value.get<int64_t>();
245245
} else if (claim_value.is<double>()) {
246246
// Float value - convert to integer (truncate)
247-
result = static_cast<long long>(claim_value.get<double>());
247+
// Float value - convert to integer using std::floor().
248+
// This ensures expiration is not extended by fractional seconds.
249+
result = static_cast<long long>(std::floor(claim_value.get<double>()));
248250
} else {
249251
if (err_msg) {
250252
*err_msg = strdup("'exp' claim must be a number (integer or float)");

0 commit comments

Comments
 (0)