From 988ad116a43d5e349fb9d2cb645a3aeace947bb3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sun, 23 Feb 2020 14:27:57 -0800 Subject: [PATCH] libsysprof-capture: check alignment in read length We require aligned frames, so we might as well enforce it in the reader. --- src/libsysprof-capture/sysprof-capture-reader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c index 0759b332..ed157621 100644 --- a/src/libsysprof-capture/sysprof-capture-reader.c +++ b/src/libsysprof-capture/sysprof-capture-reader.c @@ -356,6 +356,9 @@ sysprof_capture_reader_ensure_space_for (SysprofCaptureReader *self, g_assert (self->pos <= self->len); g_assert (len > 0); + /* Ensure alignment of length to read */ + len = (len + SYSPROF_CAPTURE_ALIGN - 1) & ~(SYSPROF_CAPTURE_ALIGN - 1); + if ((self->len - self->pos) < len) { gssize r;