diff options
author | Conrad Meyer <cem@FreeBSD.org> | 2016-12-01 17:28:45 +0000 |
---|---|---|
committer | Conrad Meyer <cem@FreeBSD.org> | 2016-12-01 17:28:45 +0000 |
commit | 103701b155899e12093f1e127b057f0b03460996 (patch) | |
tree | 32f4c4db08a871176eeaa117e10decbd0203a16d /lib/libcapsicum | |
parent | 563a19d546064e9ded08d2b8be74db34d293759c (diff) | |
download | src-103701b155899e12093f1e127b057f0b03460996.tar.gz src-103701b155899e12093f1e127b057f0b03460996.zip |
capsicum_helpers: Squash errors from closed fds
Squash EBADF from closed stdin, stdout, or stderr in caph_limit_stdio().
Any program used during special shell scripts may commonly be forked
from a parent process with closed standard stream. Do the common sense
thing for this common use.
Reported by: Iblis Lin <iblis AT hs.ntnu.edu.tw>
Reviewed by: oshogbo@ (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8657
Notes
Notes:
svn path=/head/; revision=309366
Diffstat (limited to 'lib/libcapsicum')
-rw-r--r-- | lib/libcapsicum/capsicum_helpers.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libcapsicum/capsicum_helpers.h b/lib/libcapsicum/capsicum_helpers.h index 7876f6607720..1f7655d5fb9e 100644 --- a/lib/libcapsicum/capsicum_helpers.h +++ b/lib/libcapsicum/capsicum_helpers.h @@ -94,12 +94,12 @@ caph_limit_stdout(void) static __inline int caph_limit_stdio(void) { + const int iebadf = CAPH_IGNORE_EBADF; - if (caph_limit_stdin() == -1 || caph_limit_stdout() == -1 || - caph_limit_stderr() == -1) { + if (caph_limit_stream(STDIN_FILENO, CAPH_READ | iebadf) == -1 || + caph_limit_stream(STDOUT_FILENO, CAPH_WRITE | iebadf) == -1 || + caph_limit_stream(STDERR_FILENO, CAPH_WRITE | iebadf) == -1) return (-1); - } - return (0); } |