Skip to content

Commit

Permalink
Handle OSError exception
Browse files Browse the repository at this point in the history
Handle OSError which can be returned by os.scandir

Signed-off-by: Fabrice Fontaine <[email protected]>
  • Loading branch information
ffontaine committed Mar 6, 2025
1 parent e1b174d commit 00515be
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions checksec/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
def walk_filepath_list(filepath_list: List[Path], recursive: bool = False) -> Iterator[Path]:
for path in filepath_list:
if path.is_dir() and not path.is_symlink():
if recursive:
for f in os.scandir(path):
yield from walk_filepath_list([Path(f)], recursive)
else:
yield from (Path(f) for f in os.scandir(path))
try:
if recursive:
for f in os.scandir(path):
yield from walk_filepath_list([Path(f)], recursive)
else:
yield from (Path(f) for f in os.scandir(path))
except OSError:
continue
elif path.is_file():
yield path

Expand Down

0 comments on commit 00515be

Please sign in to comment.