From f0abefa9fac1da5260d066f806ce97bf90bba964 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Thu, 14 May 2020 10:39:07 +0200 Subject: [PATCH] device: Ensure enrolled print as an appropriate type set The driver might forget to set the type of the print. Catch that error a bit earlier rather than failing when the API user tries to load it from disk again. --- libfprint/fpi-device.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libfprint/fpi-device.c b/libfprint/fpi-device.c index 93be7ec..7c1c851 100644 --- a/libfprint/fpi-device.c +++ b/libfprint/fpi-device.c @@ -912,6 +912,20 @@ fpi_device_enroll_complete (FpDevice *device, FpPrint *print, GError *error) { if (FP_IS_PRINT (print)) { + FpiPrintType print_type; + + g_object_get (print, "fpi-type", &print_type, NULL); + if (print_type == FPI_PRINT_UNDEFINED) + { + g_warning ("Driver did not set the type on the returned print!"); + g_clear_object (&print); + + error = fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL, + "Driver provided incorrect print data!"); + fpi_device_return_task_in_idle (device, FP_DEVICE_TASK_RETURN_ERROR, error); + return; + } + fpi_device_return_task_in_idle (device, FP_DEVICE_TASK_RETURN_OBJECT, print); } else