From 9fd20c306f3027882a03826d89015d9551ea32d5 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 6 Jul 2023 10:18:52 -0700 Subject: [PATCH] libsysprof-analyze: warn on non-aligned or short-frames And bail doing any further processing on the capture. --- src/libsysprof-analyze/sysprof-document.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libsysprof-analyze/sysprof-document.c b/src/libsysprof-analyze/sysprof-document.c index 5ec368ae..36844342 100644 --- a/src/libsysprof-analyze/sysprof-document.c +++ b/src/libsysprof-analyze/sysprof-document.c @@ -841,7 +841,17 @@ sysprof_document_load_worker (GTask *task, frame_len = GUINT16_SWAP_LE_BE (frame_len); if (frame_len < sizeof (SysprofCaptureFrame)) - break; + { + g_warning ("Capture contained implausibly short frame"); + break; + } + + if (frame_len % SYSPROF_CAPTURE_ALIGN != 0) + { + g_warning ("Capture contained frame not aligned to %u", + (guint)SYSPROF_CAPTURE_ALIGN); + break; + } ptr.offset = pos; ptr.length = frame_len;