freebsd-dev/usr.bin/cmp
Mark Johnston e6de40fa79 Fix handling of rights on stdio streams.
- Limit rights on stdio before opening input files.  Otherwise, open()
  may return one of the standard descriptors and we end up limiting
  rights such that we cannot read from one of the input files.
- Use caph_limit_stdio(), which suppresses EBADF, to ensure that
  we don't emit an error if one of the stdio streams is closed.
- Don't bother further limiting rights on stdin when stdin isn't going
  to be used.  Doing so correctly requires checking for a number of
  edge cases, and it doesn't provide any significant benefit.

PR:		234885
Reviewed by:	oshogbo
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18860
2019-01-17 17:36:18 +00:00
..
tests Fix file descriptor leaks in cmp(1) 2017-01-07 00:59:06 +00:00
cmp.1 cmp(1): Provide some long options 2018-05-02 01:32:34 +00:00
cmp.c Fix handling of rights on stdio streams. 2019-01-17 17:36:18 +00:00
extern.h General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
link.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
Makefile Add HAS_TESTS to all Makefiles that are currently using the 2017-08-02 08:50:42 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
misc.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
regular.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
special.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00