[sysprof] libsysprof-capture: check alignment in read length



commit 988ad116a43d5e349fb9d2cb645a3aeace947bb3
Author: Christian Hergert <chergert redhat com>
Date:   Sun Feb 23 14:27:57 2020 -0800

    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 0759b33..ed15762 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]