From 2a9ff55fe81d7fc7c86d62d5ca06aa4dbaf4f293 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 10 Jun 2019 15:41:18 -0700 Subject: fpsensor: Don't allow enrolling more than the max number of fingers This fix applies to both the console command and the host (when switching to FP_MODE_ENROLL_SESSION). BRANCH=nocturne BUG=b:124773209 TEST="fpenroll" multiple times in FP console => verify we get error after 5 attempts TEST=ectool --name=cros_fp fpmode enroll => verify we get error after 5 attempts TEST=make buildall -j Change-Id: I4e1d50f5e72d65d707e1889dee3036334f07f1eb Signed-off-by: Tom Hughes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1650036 Reviewed-by: Nicolas Norvez --- common/fpsensor/fpsensor_state.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.c index 9767ed71dc..1004c4be70 100644 --- a/common/fpsensor/fpsensor_state.c +++ b/common/fpsensor/fpsensor_state.c @@ -128,6 +128,13 @@ static int validate_fp_mode(const uint32_t mode) if (algo_mode & ~FP_VALID_MODES) return EC_ERROR_INVAL; + if ((mode & FP_MODE_ENROLL_SESSION) && + templ_valid >= FP_MAX_FINGER_COUNT) { + CPRINTS("Maximum number of fingers already enrolled: %d", + FP_MAX_FINGER_COUNT); + return EC_ERROR_INVAL; + } + /* Don't allow sensor reset if any other mode is * set (including FP_MODE_RESET_SENSOR itself). */ -- cgit v1.2.1