about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-08-30 10:25:09 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-08-30 10:25:09 +0200
commit742742fd486c1beb0d70aa734de4a0ecdbe9fca7 (patch)
treeb0af2ab135916a83496ccd3108b5a2ff2e049532 /src/tools
parent5f6104a9d30d3f295f7b05dee7d5aee89711f977 (diff)
downloadbox64-742742fd486c1beb0d70aa734de4a0ecdbe9fca7.tar.gz
box64-742742fd486c1beb0d70aa734de4a0ecdbe9fca7.zip
small improvment to x64/x86 signature detection
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/fileutils.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/tools/fileutils.c b/src/tools/fileutils.c
index 5631134b..a4b046f2 100755
--- a/src/tools/fileutils.c
+++ b/src/tools/fileutils.c
@@ -70,15 +70,12 @@ int FileIsX64ELF(const char* filename)
         return 0;
     char head[20] = {0};
     int sz = fread(head, 20, 1, f);
+    fclose(f);
     if(sz!=1) {
-        fclose(f);
         return 0;
     }
-    fclose(f);
-    if(memcmp(head, x64sign, 20)==0)
-        return 1;
     head[7] = x64lib[7];   // this one changes
-    if(memcmp(head, x64lib, 20)==0)
+    if(!memcmp(head, x64lib, 20))
         return 1;
     return 0;
 }
@@ -90,15 +87,12 @@ int FileIsX86ELF(const char* filename)
         return 0;
     char head[20] = {0};
     int sz = fread(head, 20, 1, f);
+    fclose(f);
     if(sz!=1) {
-        fclose(f);
         return 0;
     }
-    fclose(f);
-    if(memcmp(head, x86sign, 20)==0)
-        return 1;
     head[7] = x64lib[7];
-    if(memcmp(head, x86lib, 20)==0)
+    if(!memcmp(head, x86lib, 20))
         return 1;
     return 0;
 }