summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2020-05-27 08:29:01 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2020-05-27 08:29:01 -0400
commit57fd8e20784d3025eea9c4aa25ccc0723a9f4620 (patch)
tree171636277f3360e40ec8e966a6828cace241d3f9
parentbffd222841fa7de980bff99a7d34ccf97344d58a (diff)
Extra security on ELF header (calcrom)
-rw-r--r--.travis/calcrom/calcrom.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/.travis/calcrom/calcrom.cpp b/.travis/calcrom/calcrom.cpp
index fe43939a..272bcf17 100644
--- a/.travis/calcrom/calcrom.cpp
+++ b/.travis/calcrom/calcrom.cpp
@@ -11,10 +11,12 @@
* - Must be placed in ".travis/calcrom/".
*
* Changelog:
- * - 1.0.0 (26 May 2020):
+ * - 0.1.0 (26 May 2020):
* Initial implementation
- * - 1.0.1 (26 May 2020):
+ * - 0.1.1 (26 May 2020):
* Allow program to be run from wherever
+ * 0.1.2 (27 May 2020):
+ * Extra security on ELF header
*/
#include <iostream>
@@ -74,7 +76,10 @@ int main(int argc, char ** argv)
fname_s = fname_s.replace(fname_s.rfind('.'), 4, ".o");
elf.open(fname_s, ios_base::in | ios_base::binary);
elf.read((char *)&ehdr, sizeof(ehdr));
- if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
+ if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0
+ || ehdr.e_ehsize != sizeof(Elf32_Ehdr)
+ || ehdr.e_shentsize != sizeof(Elf32_Shdr))
+ {
elf.close();
stringstream ss;
ss << "Error validating " << fname_s << " as an ELF file" << endl;