tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: tail: robustness



> | 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		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index