#include <elf.h>
#include <errno.h>
#include <fcntl.h>
-#include <linux/limits.h>
+#include <limits.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
return nullptr;
}
- if (Read(fp, ptr, static_cast<long>(offset & __LONG_MAX__), size) < 0) {
+ if (Read(fp, ptr, static_cast<long>(offset & LONG_MAX), size) < 0) {
free(ptr);
return nullptr;
}
rewind(fp);
Half shdr_tab_size = ehdr->e_shentsize * ehdr->e_shnum;
Shdr shdr_tab[shdr_tab_size];
- if (Read(fp, &shdr_tab, ehdr->e_shoff, shdr_tab_size) < 0)
+ if (Read(fp, &shdr_tab, static_cast<long>(ehdr->e_shoff & LONG_MAX),
+ shdr_tab_size) < 0)
return false;
if (ehdr->e_shstrndx >= shdr_tab_size)