Cisco-Talos / clamav

ClamAV - Documentation is here: https://docs.clamav.net
https://www.clamav.net/
GNU General Public License v2.0
4.43k stars 706 forks source link

fix: Allow inline comments in clamd.conf #1308

Open userwiths opened 4 months ago

userwiths commented 4 months ago

This PR attempts to resolve the issue mentioned in #1175

  1. Regex has been changed in order to allow matching a given line even if it has a comment (separated with space or not) from the main expression.
  2. When passing through an argument, check if it contains the comment character # and if it does, try to get the content on its left side.

Thoughts:

  1. I have some doubts strtok is the best choice.
  2. Another approach, better imo, would be to get the first match from the regex expression. I failed to find an example in the project where cli_regexec returns the made matches (most likely in the 4th argument, but it seems its used mostly with NULL through out the project).
micahsnyder commented 4 months ago

Thanks for the PR! I will try to review this after we have things lined up to publish 1.4.0, or after 1.4.0 ships.