aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <>2022-12-06 13:12:33 +0000
committerdrh <>2022-12-06 13:12:33 +0000
commitb1026aeda9a6fb2ea411a37d0db9ea516e417bd2 (patch)
tree47c3c66dee048317c2b57062a0b3a483499ecd8b /src/os_unix.c
parent109f173b6f9154c2686ba022f558b874c6b5dcc5 (diff)
downloadsqlite-b1026aeda9a6fb2ea411a37d0db9ea516e417bd2.tar.gz
sqlite-b1026aeda9a6fb2ea411a37d0db9ea516e417bd2.zip
In the unix backend, when implementing the defenses against small file
descriptors, delete a file just created if it was opened with O_EXCL|O_CREAT so that it can be created again the next time through the loop. Fix for the problem described by [forum:/forumpost/699af709ab3a8ccf|forum post 699af709ab3a8ccf]. FossilOrigin-Name: c0cfe0582add87981826d124a0763482f51fae4b105b5a970dd56919f1d04d60
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index ddb6f0c07..d248703e9 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -686,6 +686,9 @@ static int robust_open(const char *z, int f, mode_t m){
break;
}
if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;
+ if( (f & (O_EXCL|O_CREAT))==(O_EXCL|O_CREAT) ){
+ (void)osUnlink(z);
+ }
osClose(fd);
sqlite3_log(SQLITE_WARNING,
"attempt to open \"%s\" as file descriptor %d", z, fd);