compress: fix minor TOCTOU when checking for existing file
authormillert <millert@openbsd.org>
Wed, 26 Oct 2022 00:40:40 +0000 (00:40 +0000)
committermillert <millert@openbsd.org>
Wed, 26 Oct 2022 00:40:40 +0000 (00:40 +0000)
commitb1f1d834a08019a5ced5bf1da4eb629660d31be9
treee307acb41ee90d9392569b4132f4bb437e25f816
parent80ef46263463eeb1861e5d6aabd0cb70bc5bef53
compress: fix minor TOCTOU when checking for existing file
Use open(2) + fstat(2) instead of stat(2) + open(2).  The file open
code has been moved into its own functions so it can be shared
between docompress() and dodecompress().
usr.bin/compress/main.c