MCPcopy Create free account
hub / github.com/MemNixFS/MemNixFS / plausible_modname

Function plausible_modname

src/os/linux/findevil.cpp:490–504  ·  view source on GitHub ↗

A loaded module has a recognizable name byte string at a known offset inside its `struct module` (offset 0x18 on 6.x x86_64). Names are printable, NUL-terminated, ≤ 56 chars.

Source from the content-addressed store, hash-verified

488// inside its `struct module` (offset 0x18 on 6.x x86_64). Names are
489// printable, NUL-terminated, ≤ 56 chars.
490bool plausible_modname(const u8* p, std::size_t len) {
491 if (len < 2) return false;
492 if (p[0] < 0x20 || p[0] >= 0x7F) return false;
493 bool seen_nul = false;
494 for (std::size_t i = 0; i < len; ++i) {
495 u8 c = p[i];
496 if (c == 0) { seen_nul = true; continue; }
497 if (seen_nul) return false;
498 if (c < 0x20 || c >= 0x7F) return false;
499 // Module names contain underscores, dashes, alphanumeric.
500 if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
501 (c >= '0' && c <= '9') || c == '_' || c == '-')) return false;
502 }
503 return seen_nul;
504}
505
506} // anon
507

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected