[libc-commits] [PATCH] D150529: [libc] Make the bump pointer explicitly return null on buffer oveerrun

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Sun May 14 22:12:48 PDT 2023


sivachandra accepted this revision.
sivachandra added inline comments.
This revision is now accepted and ready to land.


================
Comment at: libc/test/IntegrationTest/test.cpp:60
 
+static constexpr uint64_t memory_size = 16384;
 static uint8_t memory[16384];
----------------
s/`uint64_t`/`ptrdiff_t` ?
s/`memory_size`/`MEMORY_SIZE`


================
Comment at: libc/test/IntegrationTest/test.cpp:61
+static constexpr uint64_t memory_size = 16384;
 static uint8_t memory[16384];
 static uint8_t *ptr = memory;
----------------
s/`16384`/`MEMORY_SIZE`


================
Comment at: libc/test/IntegrationTest/test.cpp:69
   ptr += s;
-  return mem;
+  return static_cast<uint64_t>(ptr - memory) >= memory_size ? nullptr : mem;
 }
----------------
s/`uint64_t`/`ptrdiff_t`?


================
Comment at: libc/test/UnitTest/HermeticTestUtils.cpp:32
 // memory.
-static uint8_t memory[16384];
+static constexpr uint64_t memory_size = 16384;
+static uint8_t memory[memory_size];
----------------
Ditto.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150529/new/

https://reviews.llvm.org/D150529



More information about the libc-commits mailing list