Consistently use UINT_MAX, not -1, to indicate an invalid response.

git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@848 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2014-12-15 16:12:29 +00:00
parent 2f686b73cb
commit e959d8c160
2 changed files with 8 additions and 6 deletions

View file

@ -36,6 +36,7 @@
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
@ -98,11 +99,11 @@ oath_hotp_current(struct oath_key *k)
unsigned int code;
if (k == NULL)
return (-1);
return (UINT_MAX);
if (k->mode != om_hotp)
return (-1);
return (UINT_MAX);
if (k->counter == UINT64_MAX)
return (-1);
return (UINT_MAX);
code = oath_hotp(k->key, k->keylen, k->counter, k->digits);
k->counter += 1;
return (code);

View file

@ -33,6 +33,7 @@
# include "config.h"
#endif
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
@ -57,11 +58,11 @@ oath_totp_current(const struct oath_key *k)
uint64_t seq;
if (k == NULL)
return (-1);
return (UINT_MAX);
if (k->mode != om_totp)
return (-1);
return (UINT_MAX);
if (k->timestep == 0)
return (-1);
return (UINT_MAX);
seq = time(NULL) / k->timestep;
code = oath_hotp(k->key, k->keylen, seq, k->digits);
return (code);