Fix handling of rights on stdio streams, take two.
authorMark Johnston <markj@FreeBSD.org>
Mon, 25 Feb 2019 19:47:27 +0000 (19:47 +0000)
committerMark Johnston <markj@FreeBSD.org>
Mon, 25 Feb 2019 19:47:27 +0000 (19:47 +0000)
commit2528b7e2cb5c0d6fe0ad020dd80a1573d02a6240
tree5e40d9b51896c66d3503244bb491a37152f8f474
parent2b6010705cda9bc495bfa898995d8d5d4bc2c1fd
Fix handling of rights on stdio streams, take two.

Split the rights-limiting code into two cases: if one of the input
files isn't a regular file, use caph_limit_stream(3) instead of
open-coding the same logic; if both input files are regular files,
and the initial attempts to map them succeed, we limit the rights on
those files to CAP_MMAP_R.

Add a regression test for PR 234885.

PR: 234885
Reviewed by: delphij
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19216
usr.bin/cmp/cmp.c
usr.bin/cmp/regular.c
usr.bin/cmp/special.c
usr.bin/cmp/tests/cmp_test2.sh