VirusTotal / yara

The pattern matching swiss knife
https://virustotal.github.io/yara/
BSD 3-Clause "New" or "Revised" License
8.33k stars 1.45k forks source link

fix: check mmap result #2003

Closed secDre4mer closed 1 year ago

secDre4mer commented 1 year ago

Check if mmap failed (return value MAP_FAILED) and, if yes, exit.

secDre4mer commented 1 year ago

In addition to the original fix, improved the behaviour: if mmap on a file fails, it now falls back to an anonymous mmap() followed by pread(), same as if the file couldn't be opened. Thanks to @hillu for this idea.