HomeFreeBSD

This seems like a very trivial bug that should have been squashed a long

Description

This seems like a very trivial bug that should have been squashed a long
time ago, but for some reason it was not. Basically, without this change
dlopen(3)'ing an empty .so file would just cause application to dump core
with SIGSEGV.

Make sure the file has enough data for at least the ELF header before
mmap'ing it.

Add a test case to check that dlopen an empty file return an error.

There were a separate discussion as to whether it should be SIGBUS
instead when you try to access region mapped from an empty file,
but it's definitely SIGSEGV now, so if anyone want to check that please
be my guest.
Reviewed by: mjg, cem
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D5112

Details

Provenance
sobomaxAuthored on
Reviewer
mjg
Differential Revision
D5112: dlopen(3) crashes when opening empty .so
Parents
rS295058: Fix periodic(8) and rc(8) script inclusion to rcmds package.
Branches
Unknown
Tags
Unknown