Re: tail: robustness
Mouse <[email protected]> Sat, 10 Oct 2015 11:32:49 -0400 (EDT)
| Newsgroups | gmane.os.netbsd.devel.general |
|---|---|
| Message-ID | <[email protected]> |
> | if (fflag == 2 && fp != stdin &&
> | stat(fname, &statbuf) != -1) {
> [...]
> | fp = freopen(fname, "r", fp);
> | if (fp == NULL) {
> | ierr();
> | goto out;
> | }
Surely the right fix here is to open(), then, if that succeeds,
fstat(), then, if desired, fdopen(), fclose(), and assign? That is,
prevent the race instead of recovering from losing it?
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML [email protected]
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B