1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

dmfilemapd: fix off-by-one in fd comparison (coverity)

The function _filemap_monitor_check_file_unlinked() attempts to
test whether a fd value should be closed by comparison to zero:

        if ((fd > 0) && close(fd))
                log_error("Error closing fd %d", fd);

The test should be '>=' since 0 is a valid file descriptor.
This commit is contained in:
Bryn M. Reeves 2017-03-29 17:25:20 +01:00
parent 8658bbe3ee
commit f66bc3dab0

View File

@ -603,7 +603,7 @@ check_unlinked:
else
same = _filemap_monitor_check_same_file(fm->fd, fd);
if ((fd > 0) && close(fd))
if ((fd >= 0) && close(fd))
log_error("Error closing fd %d", fd);
if (same < 0)