VirusTotal / yara

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

fix: check mmap result #2003

Closed secDre4mer closed 8 months ago

secDre4mer commented 8 months ago

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

secDre4mer commented 8 months 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.