fp-device: Return error if trying to list a storage-less device

Devices with no storage don't allow listing prints, and if we try to do
that, we'd end up in trying to call a NULL function pointer, causing a crash

So always check if the device has storage before calling the list vfunc, and
if we fail, return an error.

Include an unit-test to verify this situation
This commit is contained in:
Marco Trevisan (Treviño)
2020-02-08 13:38:18 +01:00
committed by Benjamin Berg
parent 15a90eb451
commit 355cae1bbd
2 changed files with 27 additions and 0 deletions

View File

@@ -1213,6 +1213,14 @@ fp_device_list_prints (FpDevice *device,
return;
}
if (!fp_device_has_storage (device))
{
g_task_return_error (task,
fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED,
"Device has no storage"));
return;
}
priv->current_action = FPI_DEVICE_ACTION_LIST;
priv->current_task = g_steal_pointer (&task);
maybe_cancel_on_cancelled (device, cancellable);