mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix an integer underflow bug in libotp
Temporarily storing the offset time in an unsigned integer causes the value of the offset to underflow when a (valid) negative offset value is generated. Using a signed variable avoids this problem. https://fedorahosted.org/freeipa/ticket/5333 Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
parent
74da4f5870
commit
9e3eeadeb3
@ -199,10 +199,10 @@ static bool validate(struct otp_token *token, time_t now, ssize_t step,
|
|||||||
case TYPE_TOTP:
|
case TYPE_TOTP:
|
||||||
/* Perform optional synchronization steps. */
|
/* Perform optional synchronization steps. */
|
||||||
if (second != NULL) {
|
if (second != NULL) {
|
||||||
tmp = (step - now / token->totp.step) * token->totp.step;
|
long long off = (step - now / token->totp.step) * token->totp.step;
|
||||||
if (!writeattr(token, T("clockOffset"), tmp))
|
if (!writeattr(token, T("clockOffset"), off))
|
||||||
return false;
|
return false;
|
||||||
token->totp.offset = tmp;
|
token->totp.offset = off;
|
||||||
}
|
}
|
||||||
token->totp.watermark = step;
|
token->totp.watermark = step;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user