From e35e0b732db1132de4b5f9af050cf6939792ef8e Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 12 Jun 2010 00:23:22 +0100 Subject: [PATCH] vol: open() needs mode if called with O_CREAT If open() is called with a the O_CREAT flag, then it requires a 3rd argument, containing the mode with which to create the file. On DARWIN (when we always use O_CREAT), and on other platforms where the first call to open returned E_NOENT, we weren't doing this, and so were presumably getting a random mode of whatever garbage was on the stack. Caught by clang-analyzer Change-Id: Ic173e582e0d46f6d4cf8801dc7a6b4b393db5063 Reviewed-on: http://gerrit.openafs.org/2139 Reviewed-by: Russ Allbery Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vol/partition.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vol/partition.c b/src/vol/partition.c index b874a217b..c97668ae3 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -1205,7 +1205,11 @@ VLockPartition_r(char *name) #endif for (retries = 25; retries; retries--) { - dp->lock_fd = afs_open(partitionName, code); + if (code & O_CREAT) + dp->lock_fd = afs_open(partitionName, code, 0644); + else + dp->lock_fd = afs_open(partitionName, code); + if (dp->lock_fd != -1) break; if (errno == ENOENT) -- 2.39.5