egis_etu905: Improve the identify callback data reading

This commit is contained in:
Marco Trevisan (Treviño)
2026-06-08 15:19:54 +02:00
parent c0a9811053
commit 06ad44bc1d
+23 -18
View File
@@ -496,11 +496,10 @@ egis_etu905_list_fill_enrolled_ids_cb (FpDevice *device,
*/ */
while (read) while (read)
{ {
const guint8 *data; const guint8 data[EGIS_ETU905_FINGERPRINT_DATA_SIZE];
g_autofree gchar *print_id = NULL; g_autofree gchar *print_id = NULL;
read &= fpi_byte_reader_get_data (&reader, EGIS_ETU905_FINGERPRINT_DATA_SIZE, read &= fpi_byte_reader_get_data_static (&reader, data);
&data);
if (!read) if (!read)
break; break;
@@ -1182,15 +1181,16 @@ egis_etu905_identify_check_cb (FpDevice *device,
gsize length_in, gsize length_in,
GError *error) GError *error)
{ {
fp_dbg ("Identify check callback");
FpiDeviceEgisEtu905 *self = FPI_DEVICE_EGIS_ETU905 (device); FpiDeviceEgisEtu905 *self = FPI_DEVICE_EGIS_ETU905 (device);
gchar device_print_id[EGIS_ETU905_FINGERPRINT_DATA_SIZE]; guint8 device_print_id[EGIS_ETU905_FINGERPRINT_DATA_SIZE];
FpPrint *print = NULL; FpPrint *print = NULL;
FpPrint *verify_print = NULL; FpPrint *verify_print = NULL;
GPtrArray *prints; GPtrArray *prints;
gboolean found = FALSE; gboolean found = FALSE;
guint index; guint index;
fp_dbg ("Identify check callback");
if (error) if (error)
{ {
fpi_ssm_mark_failed (self->task_ssm, error); fpi_ssm_mark_failed (self->task_ssm, error);
@@ -1203,28 +1203,33 @@ egis_etu905_identify_check_cb (FpDevice *device,
rsp_identify_match_suffix, rsp_identify_match_suffix,
rsp_identify_match_suffix_len)) rsp_identify_match_suffix_len))
{ {
FpiByteReader reader;
/* /*
On success, there is a 32 byte array of "something"(?) in chars 14-45 On success, there is a 32 byte array of "something"(?) in chars 14-45
and then the 32 byte array ID of the matched print comes as chars 46-77 and then the 32 byte array ID of the matched print comes as chars 46-77
*/ */
memcpy (device_print_id, fpi_byte_reader_init (&reader, buffer_in, length_in);
buffer_in + EGIS_ETU905_IDENTIFY_RESPONSE_PRINT_ID_OFFSET,
EGIS_ETU905_FINGERPRINT_DATA_SIZE); if (!fpi_byte_reader_set_pos (&reader,
EGIS_ETU905_IDENTIFY_RESPONSE_PRINT_ID_OFFSET) ||
!fpi_byte_reader_get_data_static (&reader, device_print_id))
{
fpi_ssm_mark_failed (self->task_ssm,
fpi_device_error_new_msg (FP_DEVICE_ERROR_PROTO,
"Identify response too "
"short for matched print "
"id."));
return;
}
fp_dbg ("Device-reported matched print id: %s", device_print_id);
/* Create a new print from this device_print_id and then see if it matches /* Create a new print from this device_print_id and then see if it matches
* the one indicated * the one indicated
*/ */
print = fp_print_new (device); print = fp_print_new (device);
egis_etu905_set_print_data (print, device_print_id, NULL); egis_etu905_set_print_data (print, (const char *) device_print_id, NULL);
if (!print)
{
fpi_ssm_mark_failed (self->task_ssm,
fpi_device_error_new_msg (FP_DEVICE_ERROR_DATA_INVALID,
"Failed to build a print from "
"device response."));
return;
}
fp_info ("Identify successful for: %s", fp_print_get_description (print)); fp_info ("Identify successful for: %s", fp_print_get_description (print));