Skip to content

fix: Crash occurs when doing scan against a directory that is denied [#125]#129

Open
JicLotus wants to merge 2 commits intoVirusTotal:masterfrom
JicLotus:josec/fix-issue-125
Open

fix: Crash occurs when doing scan against a directory that is denied [#125]#129
JicLotus wants to merge 2 commits intoVirusTotal:masterfrom
JicLotus:josec/fix-issue-125

Conversation

@JicLotus
Copy link
Contributor

@JicLotus JicLotus commented Mar 8, 2026

Description

#125

TL;DR: Re expected behavior, as discussed in the issue here: even if we encounter errors while reading files or directories, we continue processing what can be read for scanning.


There is an existing bug that crashes the application at utils/string_reader.go:46 when a *StringArrayReader object is received. The issue arises because implementations were receiving errors as expected and sometimes a nil StringArrayReader. However, code that follows this utility, such as file/directory reading logic, does not properly verify errors before using the *StringArrayReader.

In my fix, I ensure that the function always returns a non-empty StringArrayReader containing file strings. Any errors encountered during processing are collected and returned separately, while invalid or problematic files/directories are ignored. This guarantees that downstream code always has a valid StringArrayReader, even if it does not perform thorough error checking.

Note: A more comprehensive refactor is recommended in the future, including improving error handling and adding unit tests across the repository, but this will require additional effort.

Testing

  1. Unit testing: Unit tests covering reading

  2. Manual Build Testing (macOS): Verified the new behavior when building multiple subdirectories and files with restricted permissions. For example, at the root, there are files a, b, c, d, z and subdirectories sub and sub_2. When running scan -r, the file c is permission-denied, and the directory sub_2 is skipped, while all other accessible files and directories are processed correctly.

image
  1. Compiled in all architectures make all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant