]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixed memory poisoning in slab
authorMaria Matejka <mq@ucw.cz>
Thu, 27 May 2021 08:35:33 +0000 (10:35 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 10 Sep 2021 15:38:22 +0000 (17:38 +0200)
lib/slab.c

index b0a01ae793edf84500b267800cb17077aeff35e6..8d16c433072e8d02cee84ec9892d155de59f51ce 100644 (file)
@@ -269,6 +269,9 @@ no_partial:
       goto okay;
     }
   h = alloc_page();
+#ifdef POISON
+  memset(h, 0xba, get_page_size());
+#endif
   ASSERT_DIE(SL_GET_HEAD(h) == h);
   memset(h, 0, s->head_size);
   add_head(&s->partial_heads, &h->n);
@@ -324,7 +327,12 @@ sl_free(slab *s, void *oo)
     {
       rem_node(&h->n);
       if (s->num_empty_heads >= MAX_EMPTY_HEADS)
+      {
+#ifdef POISON
+       memset(h, 0xde, get_page_size());
+#endif
        free_page(h);
+      }
       else
        {
          add_head(&s->empty_heads, &h->n);