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:
parent
2f686b73cb
commit
e959d8c160
2 changed files with 8 additions and 6 deletions
|
@ -36,6 +36,7 @@
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -98,11 +99,11 @@ oath_hotp_current(struct oath_key *k)
|
||||||
unsigned int code;
|
unsigned int code;
|
||||||
|
|
||||||
if (k == NULL)
|
if (k == NULL)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
if (k->mode != om_hotp)
|
if (k->mode != om_hotp)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
if (k->counter == UINT64_MAX)
|
if (k->counter == UINT64_MAX)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
code = oath_hotp(k->key, k->keylen, k->counter, k->digits);
|
code = oath_hotp(k->key, k->keylen, k->counter, k->digits);
|
||||||
k->counter += 1;
|
k->counter += 1;
|
||||||
return (code);
|
return (code);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -57,11 +58,11 @@ oath_totp_current(const struct oath_key *k)
|
||||||
uint64_t seq;
|
uint64_t seq;
|
||||||
|
|
||||||
if (k == NULL)
|
if (k == NULL)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
if (k->mode != om_totp)
|
if (k->mode != om_totp)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
if (k->timestep == 0)
|
if (k->timestep == 0)
|
||||||
return (-1);
|
return (UINT_MAX);
|
||||||
seq = time(NULL) / k->timestep;
|
seq = time(NULL) / k->timestep;
|
||||||
code = oath_hotp(k->key, k->keylen, seq, k->digits);
|
code = oath_hotp(k->key, k->keylen, seq, k->digits);
|
||||||
return (code);
|
return (code);
|
||||||
|
|
Loading…
Reference in a new issue