Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty results from S09 because of "grep: Argument list too long" #1461

Merged

Conversation

gluesmith2021
Copy link

@gluesmith2021 gluesmith2021 commented Feb 13, 2025

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix

  • What is the current behavior? (You can also link to an open issue here)

On a firmware that generates a sizable number of files (e.g. 13,000) under s09_firmware_base_version_check/strings_bin, S09 module fails to grep data from them and does not return any result overall.

Cause: the grep command (in the modified line in this PR) has its file pattern extended on the command line with all matching files. This exceeds the system maximum command-line length (2MB on my system, don't know how standard that is). The command does not return anything to stdout, as if no string matched lVERSION_IDENTIFIER.

Error was found by logging grep result, including stderr, from that location:

    lGREP_RESULT=$(grep -a -o -E -l "${lVERSION_IDENTIFIER}" "${LOG_PATH_MODULE}"/strings_bins/strings_* 2>&1)
    print_output "[*] DBG ${lGREP_RESULT}" 

This logs DBG /usr/bin/grep: Argument list too long for every lVERSION_IDENTIFIER

  • What is the new behavior (if this is a feature change)? If possible add a screenshot.

Given that this folder only contains strings_* files, we can call grep on the whole folder with the -r option. Results are now returned as expected from this command.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No

  • Other information:

None

@m-1-k-3 m-1-k-3 added bug Something isn't working Core modules (Sxx) The core scanning modules (Sxx modules) EMBA labels Feb 14, 2025
@m-1-k-3
Copy link
Member

m-1-k-3 commented Feb 14, 2025

Thank you for fixing this nasty bug

@m-1-k-3 m-1-k-3 merged commit 4c2e125 into e-m-b-a:master Feb 14, 2025
15 checks passed
@gluesmith2021
Copy link
Author

Thanks for the quick merge!

@gluesmith2021 gluesmith2021 deleted the fix_s09_grep_arg_list_too_long branch February 14, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Core modules (Sxx) The core scanning modules (Sxx modules) EMBA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants