-/* $OpenBSD: auth2-chall.c,v 1.54 2020/10/18 11:32:01 djm Exp $ */
+/* $OpenBSD: auth2-chall.c,v 1.55 2025/09/29 02:32:15 djm Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Per Allansson. All rights reserved.
{
size_t len;
char *t;
- int i;
+ size_t i;
if (kbdintctxt->device)
kbdint_reset_device(kbdintctxt);
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
+ if (i >= sizeof(kbdintctxt->devices_done) * 8)
+ fatal_f("internal error: too may devices");
if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
!auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
- if (strncmp(kbdintctxt->devices, devices[i]->name,
+ if (strlen(devices[i]->name) == len &&
+ memcmp(kbdintctxt->devices, devices[i]->name,
len) == 0) {
kbdintctxt->device = devices[i];
kbdintctxt->devices_done |= 1 << i;