From b02d21f9b3926120249fefa9242ebcead94fc2dc Mon Sep 17 00:00:00 2001 From: Chingis Dugarzhapov Date: Thu, 10 Apr 2014 18:37:50 +0200 Subject: raise error if no DT_SONAME found --- src/patchelf.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index a799407..c0fdfdd 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -894,7 +894,12 @@ string ElfFile::getSoname() break; } } - return soname; + if (rdi(dynSoname->d_tag) == DT_NULL) { + error("Specified ELF file does not contain any DT_SONAME entry in .dynamic section!"); + } + else { + return soname; + } } template @@ -913,6 +918,9 @@ void ElfFile::setSoname(const string & newSoname) break; } } + if (rdi(dynSoname->d_tag) == DT_NULL) + error("Specified ELF file does not contain any DT_SONAME entry in .dynamic section!"); + if (newSoname.size() <= strlen(soname)) { debug("old soname: `%s', new soname: `%s'\n", soname, newSoname.c_str()); strcpy(soname, newSoname.c_str()); -- cgit v0.12