From 742742fd486c1beb0d70aa734de4a0ecdbe9fca7 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Tue, 30 Aug 2022 10:25:09 +0200 Subject: small improvment to x64/x86 signature detection --- src/tools/fileutils.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') 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; } -- cgit 1.4.1