Skip to main content
House of lore学习

House of lore学习

主要是看着wiki 理解理解 然后自己看的glibc2.27的源码 抛开tcache部分

源码

这里是去除了不重要的tcache bin判断部分

if (in_smallbin_range (nb)){
      idx = smallbin_index (nb);
      bin = bin_at (av, idx);

      if ((victim = last (bin)) != bin)
      {
          bck = victim->bk;
          if (__glibc_unlikely (bck->fd != victim))
            malloc_printerr ("malloc(): smallbin double linked list corrupted");
          set_inuse_bit_at_offset (victim, nb);
          bin->bk = bck;
          bck->fd = bin;

          if (av != &main_arena)
	           set_non_main_arena (victim);
          check_malloced_chunk (av, victim, nb);
          void *p = chunk2mem (victim);
          alloc_perturb (p, bytes);
          return p;
      }
}

ElegyLess than 1 minutepwnheaphouse