From: Bryn M. Reeves Date: Wed, 29 Mar 2017 16:25:20 +0000 (+0100) Subject: dmfilemapd: fix off-by-one in fd comparison (coverity) X-Git-Tag: v2_02_170~106 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=f66bc3dab07f3394150536819943a5c31ce793bf;p=lvm2.git 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. --- diff --git a/daemons/dmfilemapd/dmfilemapd.c b/daemons/dmfilemapd/dmfilemapd.c index 0f3780be9..2fa51ee42 100644 --- a/daemons/dmfilemapd/dmfilemapd.c +++ b/daemons/dmfilemapd/dmfilemapd.c @@ -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)