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 <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
#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)