src/pefile.cpp: cleanup reloc handling and add more checks

This commit is contained in:
Markus F.X.J. Oberhumer
2023-10-14 19:24:44 +02:00
parent 2b371e99bd
commit d8be2ed276
6 changed files with 209 additions and 109 deletions
+4 -6
View File
@@ -35,11 +35,9 @@
// default: for any regular pointer, raw_bytes() is just the pointer itself
template <class T>
inline typename std::enable_if<std::is_pointer<T>::value && !upx::is_bounded_array<T>::value &&
(upx_is_integral<typename std::remove_pointer<T>::type>::value ||
std::is_void<typename std::remove_pointer<T>::type>::value),
T>::type
raw_bytes(T ptr, size_t size_in_bytes) {
inline
typename std::enable_if<std::is_pointer<T>::value && !upx::is_bounded_array<T>::value, T>::type
raw_bytes(T ptr, size_t size_in_bytes) {
if (size_in_bytes > 0) {
if very_unlikely (ptr == nullptr)
throwCantPack("raw_bytes unexpected NULL ptr");
@@ -53,7 +51,7 @@ raw_bytes(T ptr, size_t size_in_bytes) {
// NOTE: index == number of elements, *NOT* size in bytes!
template <class T>
inline typename std::enable_if<std::is_pointer<T>::value && !upx::is_bounded_array<T>::value &&
upx_is_integral<typename std::remove_pointer<T>::type>::value,
!std::is_void<typename std::remove_pointer<T>::type>::value,
T>::type
raw_index_bytes(T ptr, size_t index, size_t size_in_bytes) {
typedef typename std::remove_pointer<T>::type element_type;