This or one of the related commits seems to one again introduced a regression to the security checks. Attached is a test case that worked correctly before and now fails.
Joerg
#include <err.h> #include <fcntl.h> #include <unistd.h> int main(void) { const char fname[] = "foobar"; int fd; unlink(fname); fd = open(fname, O_WRONLY | O_CREAT, 0x9ed); if (fd == -1) err(1, "open failed"); if (write(fd, "foo", 3) == -1) warn("first write failed"); close(fd); fd = open(fname, O_WRONLY | O_CREAT, 0x9ed); if (fd == -1) err(1, "re-open failed"); if (write(fd, "foo", 3) == -1) warn("second write failed"); close(fd); }