[CCF Archive] Store object type eviction policy submission #3

Closed
kancel wants to merge 382 commits from kancel:ccf-archive-pr2746 into main
1 changed files with 6 additions and 2 deletions
Showing only changes of commit b2c2583252 - Show all commits

View File

@ -59,8 +59,12 @@ static size_t detectBufferPageSize(void* addr) {
bool in_range = false;
while (std::getline(smaps, line)) {
// VMA header: "start-end perms offset dev inode [pathname]"
if (!line.empty() && std::isxdigit(line[0])) {
// VMA header: "start-end perms offset dev inode [pathname]".
// Cast to unsigned char before std::isxdigit: passing a (possibly
// signed) char whose value is > 0x7F is UB, since the argument must be
// representable as unsigned char or equal EOF.
if (!line.empty() &&
std::isxdigit(static_cast<unsigned char>(line[0]))) {
unsigned long start = 0, end = 0;
if (sscanf(line.c_str(), "%lx-%lx", &start, &end) == 2) {
in_range = (target >= start && target < end);