about summary refs log tree commit diff stats
path: root/src/tools/fileutils.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-08-31 08:48:54 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-08-31 08:48:54 +0200
commitb185afa29f8a6b8d368a161dea9de7186f3f314c (patch)
tree69a4bfef28ec1791042104446a5f670e46f049eb /src/tools/fileutils.c
parent742742fd486c1beb0d70aa734de4a0ecdbe9fca7 (diff)
downloadbox64-b185afa29f8a6b8d368a161dea9de7186f3f314c.tar.gz
box64-b185afa29f8a6b8d368a161dea9de7186f3f314c.zip
Fixed x86/x86_64 binary detection (for #399)
Diffstat (limited to 'src/tools/fileutils.c')
-rwxr-xr-xsrc/tools/fileutils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c
index a4b046f2..80a0ec60 100755
--- a/src/tools/fileutils.c
+++ b/src/tools/fileutils.c
@@ -17,8 +17,8 @@
 
 static const char* x86sign = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00";
 static const char* x64sign = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00";
-static const char* x86lib  = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x03" "\x00" "\x03" "\x00";
-static const char* x64lib  = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x03" "\x00" "\x3e" "\x00";
+static const char* x86lib  = "\x7f" "ELF" "\x01" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x03" "\x00";
+static const char* x64lib  = "\x7f" "ELF" "\x02" "\x01" "\x01" "\x03" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x00" "\x02" "\x00" "\x3e" "\x00";
 
 int FileExist(const char* filename, int flags)
 {
@@ -75,6 +75,7 @@ int FileIsX64ELF(const char* filename)
         return 0;
     }
     head[7] = x64lib[7];   // this one changes
+    head[16]&=0xfe;
     if(!memcmp(head, x64lib, 20))
         return 1;
     return 0;
@@ -92,6 +93,7 @@ int FileIsX86ELF(const char* filename)
         return 0;
     }
     head[7] = x64lib[7];
+    head[16]&=0xfe;
     if(!memcmp(head, x86lib, 20))
         return 1;
     return 0;