Fix a signedness bug in OTP code

This bug caused negative token windows to wrap-around, causing issues
with TOTP authentication and (especially) synchronization.

https://fedorahosted.org/freeipa/ticket/4990

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Nathaniel McCallum
2015-04-27 10:23:49 -04:00
committed by Petr Vobornik
parent 81df7b501e
commit 978298882b

View File

@@ -489,7 +489,7 @@ bool otp_token_validate_berval(struct otp_token * const *tokens,
if (time(&now) == (time_t) -1) if (time(&now) == (time_t) -1)
return false; return false;
for (uint32_t i = 0, cnt = 1; cnt != 0; i++) { for (ssize_t i = 0, cnt = 1; cnt != 0; i++) {
cnt = 0; cnt = 0;
for (int j = 0; tokens[j] != NULL; j++) { for (int j = 0; tokens[j] != NULL; j++) {
uint32_t *secondp = NULL; uint32_t *secondp = NULL;
@@ -513,8 +513,8 @@ bool otp_token_validate_berval(struct otp_token * const *tokens,
} }
/* Validate the positive/negative steps. */ /* Validate the positive/negative steps. */
if (!validate(tokens[j], now, i, first, secondp) && if (!validate(tokens[j], now, i, first, secondp) &&
!validate(tokens[j], now, 0 - i, first, secondp)) !validate(tokens[j], now, -i, first, secondp))
continue; continue;
/* Codes validated; strip. */ /* Codes validated; strip. */