Index: src/untrusted/pll_loader/pll_loader.cc |
diff --git a/src/untrusted/pll_loader/pll_loader.cc b/src/untrusted/pll_loader/pll_loader.cc |
index aa7724e0c02ae42149d6f13dbdb39152ac9a2116..c447b9ae525497cfcc247ec900faa1e24804aa03 100644 |
--- a/src/untrusted/pll_loader/pll_loader.cc |
+++ b/src/untrusted/pll_loader/pll_loader.cc |
@@ -21,6 +21,18 @@ void *TLSBlockGetter(PLLTLSBlockGetter *closure) { |
return closure->arg; |
} |
+// Given a pathname, return the filename it points to (or NULL if the path |
+// ends with '/'). |
+const char *GetSoname(const char *path) { |
Mark Seaborn
2016/03/25 17:57:28
I'm not sure it makes sense to add this because we
Sean Klein
2016/03/25 18:43:57
Yeah, it felt like a temporary solution anyway (I
|
+ const char *base = path; |
+ while (*path) { |
+ if (*path == '/') |
+ base = path + 1; |
+ path++; |
+ } |
+ return base; |
+} |
+ |
} // namespace |
uint32_t PLLModule::HashString(const char *sp) { |
@@ -85,6 +97,15 @@ void *PLLModule::InstantiateTLSBlock() { |
} |
void ModuleSet::AddByFilename(const char *filename) { |
+ std::string soname(GetSoname(filename)); |
+ if (soname.empty()) { |
+ NaClLog(LOG_FATAL, "Invalid PLL Path: %s\n", filename); |
+ } |
+ if (sonames_.count(soname) != 0) { |
+ NaClLog(LOG_FATAL, "PLL Loader found duplicate PLL: %s\n", filename); |
+ } |
+ sonames_.insert(soname); |
+ |
void *pso_root; |
int err = pnacl_load_elf_file(filename, &pso_root); |
if (err != 0) { |