summaryrefslogtreecommitdiff
path: root/auth2-chall.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth2-chall.c')
-rw-r--r--auth2-chall.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/auth2-chall.c b/auth2-chall.c
index 6505d4009..98f3093ce 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-chall.c,v 1.36 2012/12/03 00:14:06 djm Exp $ */ 1/* $OpenBSD: auth2-chall.c,v 1.38 2013/05/17 00:13:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2001 Per Allansson. All rights reserved. 4 * Copyright (c) 2001 Per Allansson. All rights reserved.
@@ -147,15 +147,13 @@ kbdint_free(KbdintAuthctxt *kbdintctxt)
147{ 147{
148 if (kbdintctxt->device) 148 if (kbdintctxt->device)
149 kbdint_reset_device(kbdintctxt); 149 kbdint_reset_device(kbdintctxt);
150 if (kbdintctxt->devices) { 150 free(kbdintctxt->devices);
151 xfree(kbdintctxt->devices); 151 bzero(kbdintctxt, sizeof(*kbdintctxt));
152 kbdintctxt->devices = NULL; 152 free(kbdintctxt);
153 }
154 xfree(kbdintctxt);
155} 153}
156/* get next device */ 154/* get next device */
157static int 155static int
158kbdint_next_device(KbdintAuthctxt *kbdintctxt) 156kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
159{ 157{
160 size_t len; 158 size_t len;
161 char *t; 159 char *t;
@@ -169,12 +167,16 @@ kbdint_next_device(KbdintAuthctxt *kbdintctxt)
169 167
170 if (len == 0) 168 if (len == 0)
171 break; 169 break;
172 for (i = 0; devices[i]; i++) 170 for (i = 0; devices[i]; i++) {
171 if (!auth2_method_allowed(authctxt,
172 "keyboard-interactive", devices[i]->name))
173 continue;
173 if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0) 174 if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0)
174 kbdintctxt->device = devices[i]; 175 kbdintctxt->device = devices[i];
176 }
175 t = kbdintctxt->devices; 177 t = kbdintctxt->devices;
176 kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL; 178 kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
177 xfree(t); 179 free(t);
178 debug2("kbdint_next_device: devices %s", kbdintctxt->devices ? 180 debug2("kbdint_next_device: devices %s", kbdintctxt->devices ?
179 kbdintctxt->devices : "<empty>"); 181 kbdintctxt->devices : "<empty>");
180 } while (kbdintctxt->devices && !kbdintctxt->device); 182 } while (kbdintctxt->devices && !kbdintctxt->device);
@@ -221,7 +223,7 @@ auth2_challenge_start(Authctxt *authctxt)
221 debug2("auth2_challenge_start: devices %s", 223 debug2("auth2_challenge_start: devices %s",
222 kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); 224 kbdintctxt->devices ? kbdintctxt->devices : "<empty>");
223 225
224 if (kbdint_next_device(kbdintctxt) == 0) { 226 if (kbdint_next_device(authctxt, kbdintctxt) == 0) {
225 auth2_challenge_stop(authctxt); 227 auth2_challenge_stop(authctxt);
226 return 0; 228 return 0;
227 } 229 }
@@ -268,11 +270,11 @@ send_userauth_info_request(Authctxt *authctxt)
268 packet_write_wait(); 270 packet_write_wait();
269 271
270 for (i = 0; i < kbdintctxt->nreq; i++) 272 for (i = 0; i < kbdintctxt->nreq; i++)
271 xfree(prompts[i]); 273 free(prompts[i]);
272 xfree(prompts); 274 free(prompts);
273 xfree(echo_on); 275 free(echo_on);
274 xfree(name); 276 free(name);
275 xfree(instr); 277 free(instr);
276 return 1; 278 return 1;
277} 279}
278 280
@@ -311,10 +313,9 @@ input_userauth_info_response(int type, u_int32_t seq, void *ctxt)
311 313
312 for (i = 0; i < nresp; i++) { 314 for (i = 0; i < nresp; i++) {
313 memset(response[i], 'r', strlen(response[i])); 315 memset(response[i], 'r', strlen(response[i]));
314 xfree(response[i]); 316 free(response[i]);
315 } 317 }
316 if (response) 318 free(response);
317 xfree(response);
318 319
319 switch (res) { 320 switch (res) {
320 case 0: 321 case 0: