1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

Validate that the supplied file is not empty before trying mmap(2) it

and access the pages associated with it.

Submitted by:	Wojciech A. Koszek
PR:		bin/91411
MFC after:	1 week
This commit is contained in:
Christian S.J. Peron 2006-01-15 20:30:13 +00:00
parent 323203d389
commit 65efc5ee23
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=154404

View File

@ -179,6 +179,11 @@ _kvm_open(kd, uf, mf, flag, errout)
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
if (S_ISREG(st.st_mode) && st.st_size <= 0) {
errno = EINVAL;
_kvm_syserr(kd, kd->program, "empty file");
goto failed;
}
if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;