Infinite Loop fix for MachOFileFInder

This commit is contained in:
Karmaz95
2024-11-14 21:46:05 +01:00
parent 5211e1b5fd
commit 1d8edc592d
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -4,6 +4,7 @@ import sys
import argparse
import struct
from concurrent.futures import ThreadPoolExecutor
import stat
class MachOFileFinder:
# Mach-O and FAT magic numbers
@@ -37,6 +38,14 @@ class MachOFileFinder:
self.recursive = recursive
self.only_arm64 = only_arm64
def isRegularFile(self, file_path):
"""Check if the specified file is a regular file."""
try:
return stat.S_ISREG(os.stat(file_path).st_mode)
except (OSError, IOError) as e:
# print(f"Error checking file type for {file_path}: {e}")
return False
def determineFileEndianness(self, magic):
"""Determine the endianness of the file based on the magic number."""
if magic in (self.MACHO_CIGAM, self.MACHO_CIGAM_64, self.FAT_CIGAM):
@@ -161,6 +170,11 @@ class MachOFileFinder:
for file_name in files:
file_path = os.path.abspath(os.path.join(root, file_name))
# Check if the file is a regular file before processing
if not self.isRegularFile(file_path):
#print(f"Skipping non-regular file: {file_path}")
continue
# Check if the file is a Mach-O binary or FAT binary
file_type = self.getMachoInfo(file_path)
if file_type: