vfs301: Handle unexpected data length gracefully

This commit is contained in:
Marco Trevisan (Treviño)
2026-07-13 08:13:46 +00:00
committed by Marco Trevisan
parent 7f9504afd5
commit 973aa65d4c
+7 -2
View File
@@ -348,7 +348,11 @@ vfs301_extract_image (FpDeviceVfs301 *vfs, guint8 *output, int *output_height
int last_line; int last_line;
int i; int i;
g_assert (vfs->scanline_count >= 1); if (vfs->scanline_count < 1 || scanlines == NULL)
{
*output_height = 0;
g_return_if_reached ();
}
*output_height = 1; *output_height = 1;
memcpy (output, scanlines, VFS301_FP_OUTPUT_WIDTH); memcpy (output, scanlines, VFS301_FP_OUTPUT_WIDTH);
@@ -447,7 +451,8 @@ vfs301_proto_process_data (FpDeviceVfs301 *dev, int first_block, const guint8 *b
if (first_block) if (first_block)
{ {
g_assert (len >= VFS301_FP_FRAME_SIZE); if (len < VFS301_FP_FRAME_SIZE)
g_return_val_if_reached (img_process_data (first_block, dev, buf, 0));
/* Skip bytes until start_sequence is found */ /* Skip bytes until start_sequence is found */
for (i = 0; i < VFS301_FP_FRAME_SIZE; i++, buf++, len--) for (i = 0; i < VFS301_FP_FRAME_SIZE; i++, buf++, len--)