]> sourceware.org Git - lvm2.git/commitdiff
dmfilemapd: fix off-by-one in fd comparison (coverity)
authorBryn M. Reeves <bmr@redhat.com>
Wed, 29 Mar 2017 16:25:20 +0000 (17:25 +0100)
committerBryn M. Reeves <bmr@redhat.com>
Wed, 29 Mar 2017 17:34:19 +0000 (18:34 +0100)
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.

daemons/dmfilemapd/dmfilemapd.c

index 0f3780be975183e78fdead9d46df1db9e2f0712c..2fa51ee4263a29ec642e057ad8102fbaf144c7ac 100644 (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)
This page took 0.032826 seconds and 5 git commands to generate.