diff options
author | Breno Rodrigues GuimarĂ£es <brenorg@gmail.com> | 2023-02-22 06:42:46 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 06:42:46 -0300 |
commit | 0611392aaae61da0c4fb0b41b4fb98a19d4b910f (patch) | |
tree | 3f69659f9f4100548f83f2bdae6e73c0e55864f5 | |
parent | 16f13b4194d75ad2dbb9f48ce75268b4cc9e7e6a (diff) | |
download | patchelf-0611392aaae61da0c4fb0b41b4fb98a19d4b910f.tar.gz |
Update patchelf.cc
Untested. Coding from github while my VM is acting up.
-rw-r--r-- | src/patchelf.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc index 19994c5..924c4cf 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -2549,18 +2549,24 @@ static int mainWrapped(int argc, char * * argv) renameDynamicSymbols = true; if (++i == argc) error("missing argument"); - std::ifstream infile(argv[i]); - if (!infile) error(fmt("Cannot open map file ", argv[i])); + const char* fname = argv[i]; + std::ifstream infile(fname); + if (!infile) error(fmt("Cannot open map file ", fname)); - std::string from, to; - while (true) + std::string line, from, to; + size_t lineCount = 1; + while (std::getline(infile, line)) { - if (!(infile >> from)) + std::istringstream iss(line); + if (!(iss >> from)) break; - if (!(infile >> to)) - error("Odd number of symbols in map file"); + if (!(iss >> to)) + error(fmt(fname, ":", lineCount, ": Map file line is missing the second element")); if (symbolsToRenameKeys.count(from)) - error(fmt("Symbol appears twice in the map file: ", from.c_str())); + error(fmt(fname, ":", lineCount, ": Name ", from, " appears twice in the map file")); + if (from.find('@') != std::string_view::npos || to.find('@') != std::string_view::npos) + error(fmt(fname, ":", lineCount, ": Name pair contains version tag: ", from, " ", to)); + lineCount++; symbolsToRename[*symbolsToRenameKeys.insert(from).first] = to; } } |