NetBpfLoad: make 2 slashes abort

This cannot happen (it's a .c misconfig if it does)

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5d82c7bb8c0214f5ffcc0ce391daddb9fe6a3295
This commit is contained in:
Maciej Żenczykowski 2025-08-04 11:50:41 -07:00
commit 806087d4a1

View file

@ -431,8 +431,15 @@ int readCodeSections(ElfObject& elfObj, vector<codeSection>& cs) {
string oldName = name;
// convert all slashes to underscores
std::replace(name.begin(), name.end(), '/', '_');
// Find the first slash
size_t first_slash_pos = name.find('/');
// If a slash is found, replace it
if (first_slash_pos != std::string::npos) {
name[first_slash_pos] = '_';
if (name.find('/') != std::string::npos) abort(); // There should only be one!
}
cs_temp.name = name;