[sysprof] capture: do 24 bit counter identifier checks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] capture: do 24 bit counter identifier checks
- Date: Thu, 17 May 2018 11:29:40 +0000 (UTC)
commit 1ef68eeb3186b78a0807421505d2044258dcbb3e
Author: Christian Hergert <chergert redhat com>
Date: Thu May 17 12:29:04 2018 +0100
capture: do 24 bit counter identifier checks
Max uint was more than we allow, since we steal the top 8 bits for some
other data. This instead checks for 24-bit and warns if the user tries to
store a counter value that was not registered.
lib/capture/sp-capture-writer.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/lib/capture/sp-capture-writer.c b/lib/capture/sp-capture-writer.c
index d61490d..f29bfb7 100644
--- a/lib/capture/sp-capture-writer.c
+++ b/lib/capture/sp-capture-writer.c
@@ -34,6 +34,7 @@
#define DEFAULT_BUFFER_SIZE (getpagesize() * 64L)
#define INVALID_ADDRESS (G_GUINT64_CONSTANT(0))
+#define MAX_COUNTERS ((1 << 24) - 1)
typedef struct
{
@@ -1079,7 +1080,15 @@ sp_capture_writer_define_counters (SpCaptureWriter *self,
def->n_counters = n_counters;
for (i = 0; i < n_counters; i++)
- def->counters[i] = counters[i];
+ {
+ if (counters[i].id >= self->next_counter_id)
+ {
+ g_warning ("Counter %u has not been registered.", counters[i].id);
+ continue;
+ }
+
+ def->counters[i] = counters[i];
+ }
self->stat.frame_count[SP_CAPTURE_FRAME_CTRDEF]++;
@@ -1171,7 +1180,7 @@ sp_capture_writer_request_counter (SpCaptureWriter *self,
g_assert (self != NULL);
- if (G_MAXUINT - n_counters < self->next_counter_id)
+ if (MAX_COUNTERS - n_counters < self->next_counter_id)
return 0;
ret = self->next_counter_id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]