From 2aa02d44b21dc647605e31951bb5e7dafd5ba25b Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Sat, 28 Mar 2020 13:23:40 -0400 Subject: [PATCH] dont return index >= ctap_rk_size() Fixes issue found by @My1: https://github.com/solokeys/solo/issues/407 --- fido2/ctap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fido2/ctap.c b/fido2/ctap.c index 46afb54..3ccb9cb 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -1587,18 +1587,15 @@ static int scan_for_next_rk(int index, uint8_t * initialRpIdHash){ if (initialRpIdHash != NULL) { memmove(lastRpIdHash, initialRpIdHash, 32); - index = 0; + index = -1; } else { ctap_load_rk(index, &rk); memmove(lastRpIdHash, rk.id.rpIdHash, 32); - index++; } - ctap_load_rk(index, &rk); - - while ( memcmp( rk.id.rpIdHash, lastRpIdHash, 32 ) != 0 ) + do { index++; if ((unsigned int)index >= ctap_rk_size()) @@ -1607,6 +1604,7 @@ static int scan_for_next_rk(int index, uint8_t * initialRpIdHash){ } ctap_load_rk(index, &rk); } + while ( memcmp( rk.id.rpIdHash, lastRpIdHash, 32 ) != 0 ); return index; }