mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
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. Reported by: Coverity CID: 1006123 Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
699b3c8722
commit
7bfdbca596
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299484
|
@ -199,7 +199,10 @@ randomize_fd(int fd, int type, int unique, double denom)
|
|||
}
|
||||
}
|
||||
|
||||
if (fd >= 0) {
|
||||
(void)close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
||||
/* Necessary evil to compensate for files that don't end with a newline */
|
||||
if (bufc != i) {
|
||||
|
|
Loading…
Reference in a new issue