Initialize error string and check for NULL from strdup.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1081 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -50,7 +50,12 @@ otp_challenge (OtpContext *ctx, char *user, char *str, size_t len)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ctx->challengep = 0;
|
ctx->challengep = 0;
|
||||||
|
ctx->err = NULL;
|
||||||
ctx->user = strdup(user);
|
ctx->user = strdup(user);
|
||||||
|
if (ctx->user == NULL) {
|
||||||
|
ctx->err = "Out of memory";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
dbm = otp_db_open ();
|
dbm = otp_db_open ();
|
||||||
if (dbm == NULL) {
|
if (dbm == NULL) {
|
||||||
ctx->err = "Cannot open database";
|
ctx->err = "Cannot open database";
|
||||||
@@ -61,7 +66,6 @@ otp_challenge (OtpContext *ctx, char *user, char *str, size_t len)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
sprintf (str, "[ otp-%s %u %s ]", ctx->alg->name, ctx->n-1, ctx->seed);
|
sprintf (str, "[ otp-%s %u %s ]", ctx->alg->name, ctx->n-1, ctx->seed);
|
||||||
ctx->err = NULL;
|
|
||||||
ctx->challengep = 1;
|
ctx->challengep = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user