1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-02-08 03:54:18 +01:00

Move code around slightly to make merging with Fredrik easier

This commit is contained in:
Tollef Fog Heen 2011-03-18 23:01:46 +01:00
parent 839b33a0a1
commit 72d1f4bba9

View File

@ -396,6 +396,11 @@ do_challenge_response(struct cfg *cfg, const char *username)
if (! load_chalresp_state(f, &state)) if (! load_chalresp_state(f, &state))
goto out; goto out;
if (fclose(f) < 0) {
f = NULL;
goto out;
}
if (! challenge_response(yk, state.slot, state.challenge, state.challenge_len, if (! challenge_response(yk, state.slot, state.challenge, state.challenge_len,
true, flags, false, true, flags, false,
buf, sizeof(buf), &response_len)) { buf, sizeof(buf), &response_len)) {
@ -436,12 +441,14 @@ do_challenge_response(struct cfg *cfg, const char *username)
/* /*
* Write the challenge and response we will expect the next time to the state file. * Write the challenge and response we will expect the next time to the state file.
*/ */
/* Write out the new file */ if (response_len > sizeof(state.response)) {
if (fclose(f) < 0) { D(("Got too long response ??? (%i/%i)", response_len, sizeof(state.response)));
f = NULL;
goto out; goto out;
} }
memcpy (state.response, buf, response_len);
state.response_len = response_len;
/* Write out the new file */
tmpfile = malloc(strlen(userfile) + 1 + 4); tmpfile = malloc(strlen(userfile) + 1 + 4);
if (! tmpfile) if (! tmpfile)
goto out; goto out;
@ -452,16 +459,8 @@ do_challenge_response(struct cfg *cfg, const char *username)
if (! f) if (! f)
goto out; goto out;
if (response_len > sizeof(state.response)) {
D(("Got too long response ??? (%i/%i)", response_len, sizeof(state.response)));
goto out;
}
memcpy (state.response, buf, response_len);
state.response_len = response_len;
if (! write_chalresp_state (f, &state)) if (! write_chalresp_state (f, &state))
goto out; goto out;
if (fclose(f) < 0) { if (fclose(f) < 0) {
f = NULL; f = NULL;
goto out; goto out;