3 ms·
fstat is a more recent system call than stat, so old code bases do not use it, and mail.local is quite ancient. Although a quick lookup tells me that it appear
by gpvos 10y ago
fstat is a more recent system call than stat, so old code bases do not use it, and mail.local is quite ancient.
Although a quick lookup tells me that it appeared in 4.3BSD-Tahoe (June 1988) and SysVR4 (October 1988), so one would have expected all reasonable distributions to have gotten with the program by now.
- jandrese 10y agoA little digging suggests that mail.local appeared in Version 7 Unix from 1979, so it is not a surprise that it doesn't include a syscall invented 9 years later. Still, that syscall is 28 years old now. It's kind of embarrassing that nobody has gone though and checked for ancient and obvious privilege escalation issues like this. Or I guess they have, but on different OSes. This is one big downside to fragmentation, getting fixes distributed to all of the fragments.
- caf 10y agofstat() isn't the complete fix here - it doesn't protect you against opening/creating an unintended file through a symlink, for which you need O_NOFOLLOW (which is a bit more recent).