return errors

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@982 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1996-11-16 17:54:17 +00:00
parent 7a2f2857d5
commit a4237d6c48
3 changed files with 21 additions and 7 deletions

View File

@@ -89,18 +89,24 @@ otp_get (void *v, OtpContext *ctx)
key.dptr = ctx->user;
dat = dbm_fetch (dbm, key);
if (dat.dptr == NULL)
if (dat.dptr == NULL) {
ctx->err = "Entry not found";
return -1;
}
p = dat.dptr;
time(&now);
memcpy (&then, p, sizeof(then));
if (then && now - then < OTP_USER_TIMEOUT)
if (then && now - then < OTP_USER_TIMEOUT) {
ctx->err = "Entry locked";
return -1;
}
memcpy (p, &now, sizeof(now));
p += sizeof(now);
ctx->alg = otp_find_alg (p);
if (ctx->alg == NULL)
if (ctx->alg == NULL) {
ctx->err = "Bad algorithm";
return -1;
}
p += strlen(p) + 1;
ctx->n = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
p += 4;