egis_etu905: Sanitize print data parsing

This commit is contained in:
Marco Trevisan (Treviño)
2026-06-08 13:47:41 +02:00
parent 65c3dcb1eb
commit 5b51f9c8cc
+17 -8
View File
@@ -318,7 +318,7 @@ static guint16
egis_etu905_get_check_bytes (FpiByteReader *reader) egis_etu905_get_check_bytes (FpiByteReader *reader)
{ {
fp_dbg ("Get check bytes"); fp_dbg ("Get check bytes");
size_t sum_values = 0; guint64 sum_values = 0;
guint16 val; guint16 val;
fpi_byte_reader_set_pos (reader, 0); fpi_byte_reader_set_pos (reader, 0);
@@ -562,8 +562,6 @@ egis_etu905_get_delete_cmd (FpDevice *device,
const guchar *print_data_id = NULL; const guchar *print_data_id = NULL;
gsize print_data_id_len = 0; gsize print_data_id_len = 0;
g_autofree gchar *print_description = NULL; g_autofree gchar *print_description = NULL;
g_autofree guchar *enrolled_print_id = NULL;
g_autofree guchar *result = NULL;
gboolean written = TRUE; gboolean written = TRUE;
/* /*
@@ -639,7 +637,8 @@ egis_etu905_get_delete_cmd (FpDevice *device,
g_object_get (delete_print, "description", &print_description, NULL); g_object_get (delete_print, "description", &print_description, NULL);
g_object_get (delete_print, "fpi-data", &print_data, NULL); g_object_get (delete_print, "fpi-data", &print_data, NULL);
if (!g_variant_check_format_string (print_data, "(@ay)", FALSE)) if (!print_data ||
!g_variant_check_format_string (print_data, "(@ay)", FALSE))
{ {
fpi_ssm_mark_failed (self->task_ssm, fpi_ssm_mark_failed (self->task_ssm,
fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID)); fpi_device_error_new (FP_DEVICE_ERROR_DATA_INVALID));
@@ -650,11 +649,21 @@ egis_etu905_get_delete_cmd (FpDevice *device,
print_data_id = g_variant_get_fixed_array (print_data_id_var, print_data_id = g_variant_get_fixed_array (print_data_id_var,
&print_data_id_len, sizeof (guchar)); &print_data_id_len, sizeof (guchar));
if (!g_str_has_prefix (print_description, "FP")) if (print_data_id_len != EGIS_ETU905_FINGERPRINT_DATA_SIZE)
fp_dbg ("Fingerprint '%s' was not created by libfprint; deleting anyway.", {
print_description); fpi_ssm_mark_failed (self->task_ssm,
fpi_device_error_new_msg (FP_DEVICE_ERROR_DATA_INVALID,
"Stored print id has "
"unexpected length %zu",
print_data_id_len));
return NULL;
}
fp_info ("Delete fingerprint %s", print_description); if (!print_description || !g_str_has_prefix (print_description, "FP"))
fp_dbg ("Fingerprint '%s' was not created by libfprint; deleting anyway.",
print_description ? print_description : "(null)");
fp_info ("Delete fingerprint %s", print_description ? print_description : "(null)");
written &= fpi_byte_writer_put_data (&writer, print_data_id, written &= fpi_byte_writer_put_data (&writer, print_data_id,
EGIS_ETU905_FINGERPRINT_DATA_SIZE); EGIS_ETU905_FINGERPRINT_DATA_SIZE);