diff options
author | truckman <truckman@FreeBSD.org> | 2016-06-15 06:27:43 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2016-06-15 06:27:43 +0000 |
commit | 6d64f4d6b9a42023c870cd90f9d20ce62b1e1694 (patch) | |
tree | 2d6932417f9daa445d960ce00db32c9ca43aa48a /contrib/diff/lib/basename.c | |
parent | d7c7919b61f490e8f4a8fb07fbd6011d8005fdf5 (diff) | |
download | FreeBSD-src-6d64f4d6b9a42023c870cd90f9d20ce62b1e1694.zip FreeBSD-src-6d64f4d6b9a42023c870cd90f9d20ce62b1e1694.tar.gz |
MFC r299484, r301574
r299484 | cem | 2016-05-11 15:04:28 -0700 (Wed, 11 May 2016) | 13 lines
random(6): Fix double-close
In the case where a file lacks a trailing newline, there is some "evil" code to
reverse goto the tokenizing code ("make_token") for the final token in the
file. In this case, 'fd' is closed more than once. Use a negative sentinel
value to guard close(2), preventing the double close.
Ideally, this code would be restructured to avoid this ugly construction.
r301574 | truckman | 2016-06-07 19:14:05 -0700 (Tue, 07 Jun 2016) | 15 lines
Fix a (false positive?) Argument cannot be negative coverity defect.
Rather than guarding close(fd) with an fd >= 0 test and setting fd
to -1 when it is closed to avoid a potential double-close, just
move the close() call after the conditional "goto make_token". This
moves the close() call totally outside the loop to avoid the
possibility of calling it twice. This should also prevent a Coverity
warning about checking fd for validity after it was previously passed
to read().
Reported by: Coverity
CID: 1006123, 1355335
Diffstat (limited to 'contrib/diff/lib/basename.c')
0 files changed, 0 insertions, 0 deletions