commit 1e4adc512e1901e2c031bd375afe2825692620a5
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sat Sep 12 23:49:32 2015 +0200
In fileLock, take in account the case where the file cannot be opened
overity issue 23352
diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index bab9687..4c37fa1 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -1219,14 +1219,17 @@ int fileLock(const char * lock_file)
int fd = -1;
#if defined(HAVE_LOCKF)
fd = open(lock_file, O_CREAT|O_APPEND|O_SYNC|O_RDWR, 0666);
+ if (fd == -1)
+ return -1;
if (lockf(fd, F_LOCK, 0) != 0) {
close(fd);
- return(-1);
+ return -1;
}
#endif
- return(fd);
+ return fd;
}
+
void fileUnlock(int fd, const char * /* lock_file*/)
{
#if defined(HAVE_LOCKF)