diff --git a/lib/utils_device.c b/lib/utils_device.c index 5845fa31..8f582b5f 100644 --- a/lib/utils_device.c +++ b/lib/utils_device.c @@ -351,7 +351,7 @@ int device_open_excl(struct crypt_device *cd, struct device *device, int flags) else { /* open(2) with O_EXCL (w/o O_CREAT) on regular file is undefined behaviour according to man page */ /* coverity[toctou] */ - device->dev_fd_excl = open(path, O_RDONLY | O_EXCL); + device->dev_fd_excl = open(path, O_RDONLY | O_EXCL); /* lgtm[cpp/toctou-race-condition] */ if (device->dev_fd_excl < 0) return errno == EBUSY ? -EBUSY : device->dev_fd_excl; if (fstat(device->dev_fd_excl, &st) || !S_ISBLK(st.st_mode)) { diff --git a/lib/utils_device_locking.c b/lib/utils_device_locking.c index 2d92bfac..a0b6fa5e 100644 --- a/lib/utils_device_locking.c +++ b/lib/utils_device_locking.c @@ -229,7 +229,7 @@ static void release_lock_handle(struct crypt_device *cd, struct crypt_lock_handl !stat(res, &buf_b) && /* does path file still exist? */ same_inode(buf_a, buf_b)) { /* is it same id as the one referenced by fd? */ /* coverity[toctou] */ - if (unlink(res)) /* yes? unlink the file */ + if (unlink(res)) /* yes? unlink the file. lgtm[cpp/toctou-race-condition] */ log_dbg(cd, "Failed to unlink resource file: %s", res); } @@ -240,7 +240,7 @@ static void release_lock_handle(struct crypt_device *cd, struct crypt_lock_handl !stat(res, &buf_b) && /* does path file still exist? */ same_inode(buf_a, buf_b)) { /* is it same id as the one referenced by fd? */ /* coverity[toctou] */ - if (unlink(res)) /* yes? unlink the file */ + if (unlink(res)) /* yes? unlink the file. lgtm[cpp/toctou-race-condition] */ log_dbg(cd, "Failed to unlink resource file: %s", res); } diff --git a/src/utils_blockdev.c b/src/utils_blockdev.c index e055bf3e..bfb8a344 100644 --- a/src/utils_blockdev.c +++ b/src/utils_blockdev.c @@ -281,7 +281,7 @@ int tools_wipe_all_signatures(const char *path) /* better than opening regular file with O_EXCL (undefined) */ /* coverity[toctou] */ - fd = open(path, flags); + fd = open(path, flags); /* lgtm[cpp/toctou-race-condition] */ if (fd < 0) { if (errno == EBUSY) log_err(_("Device %s is in use. Cannot proceed with format operation."), path); diff --git a/src/utils_reencrypt_luks1.c b/src/utils_reencrypt_luks1.c index 7fd7027f..f24bffcd 100644 --- a/src/utils_reencrypt_luks1.c +++ b/src/utils_reencrypt_luks1.c @@ -123,7 +123,7 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s } /* coverity[toctou] */ - devfd = open(device, O_RDWR | ((S_ISBLK(st.st_mode) && exclusive) ? O_EXCL : 0)); + devfd = open(device, O_RDWR | ((S_ISBLK(st.st_mode) && exclusive) ? O_EXCL : 0)); /* lgtm[cpp/toctou-race-condition] */ if (devfd == -1) { if (errno == EBUSY) { log_err(_("Cannot exclusively open %s, device in use."),