aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-10-26 19:58:56 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-10-26 19:58:56 +0000
commitdd3867b46e28d020a2bb8ae5513d826abfedf958 (patch)
tree0f632468ccd7adcde69c53112a5166fa87578168
parent9bd1a81d8d6c6692aa49b988413c135f3b055cba (diff)
downloadpaludis-dd3867b46e28d020a2bb8ae5513d826abfedf958.tar.gz
paludis-dd3867b46e28d020a2bb8ae5513d826abfedf958.tar.xz
More strictness.
-rw-r--r--src/clients/reconcilio/littlelf/elf_relocation_section.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/clients/reconcilio/littlelf/elf_relocation_section.cc b/src/clients/reconcilio/littlelf/elf_relocation_section.cc
index 06e03ea..5a3250d 100644
--- a/src/clients/reconcilio/littlelf/elf_relocation_section.cc
+++ b/src/clients/reconcilio/littlelf/elf_relocation_section.cc
@@ -1,6 +1,7 @@
#include "elf_relocation_section.hh"
#include "elf_types.hh"
+#include "elf.hh"
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
@@ -51,14 +52,15 @@ RelocationSection<ElfType_, Relocation_>::RelocationSection(const typename ElfTy
Section<ElfType_>(shdr),
PrivateImplementationPattern<RelocationSection>(new Implementation<RelocationSection>)
{
- if (0 != shdr.sh_entsize)
- {
- std::vector<typename Relocation_::Type> relocations(shdr.sh_size / shdr.sh_entsize);
- stream.seekg(shdr.sh_offset, std::ios::beg);
- stream.read(reinterpret_cast<char *>(&relocations.front()), shdr.sh_size);
- for (typename std::vector<typename Relocation_::Type>::iterator i = relocations.begin(); i != relocations.end(); ++i)
- _imp->relocations.push_back(typename Relocation_::Entry(*i));
- }
+ if (sizeof(typename Relocation_::Type) != shdr.sh_entsize)
+ throw InvalidElfFileError();
+
+ std::vector<typename Relocation_::Type> relocations(shdr.sh_size / sizeof(typename Relocation_::Type));
+ stream.seekg(shdr.sh_offset, std::ios::beg);
+ stream.read(reinterpret_cast<char *>(&relocations.front()), shdr.sh_size);
+
+ for (typename std::vector<typename Relocation_::Type>::iterator i = relocations.begin(); i != relocations.end(); ++i)
+ _imp->relocations.push_back(typename Relocation_::Entry(*i));
}
template <typename ElfType_, typename Relocation_>