Hello David,
that statement is correct. The file descriptor of /dev/full is not needed. It is just to assure that fd 0, 1 and 2 are in use. This is an interesting way to implement a state machine abusing the C relational operator == and the return values of the open() function, which always returns -1, when the file cannot be opened.
If there are no files open, open("/dev/full", mode) may return 0, 1 or 2. Your "patch" is wrong and will break the application logic.
See also here: [1]
Regards
Marius
[1] https://lists.gnu.org/archive/html/bug-tar/2019-01/msg00004.html
Gesendet: Freitag, 08. Januar 2021 um 15:54 Uhr
Von: "David Binderman" <dcb...@hotmail.com>
An: "bug-tar@gnu.org" <bug-tar@gnu.org>
Betreff: tar-1.33 bug report
Von: "David Binderman" <dcb...@hotmail.com>
An: "bug-tar@gnu.org" <bug-tar@gnu.org>
Betreff: tar-1.33 bug report
Hello there,
tar-1.33/lib/stdopen.c:63:22: style: Suspicious condition
Source code is
if (mode == O_RDONLY
|| (new_fd = open (c) != fd))
Maybe better code:
if (mode == O_RDONLY
|| ((new_fd = open ("/dev/full", mode)) != fd))
Regards
David Binderman
tar-1.33/lib/stdopen.c:63:22: style: Suspicious condition
Source code is
if (mode == O_RDONLY
|| (new_fd = open (c) != fd))
Maybe better code:
if (mode == O_RDONLY
|| ((new_fd = open ("/dev/full", mode)) != fd))
Regards
David Binderman