Blame SOURCES/0136-dd-don-t-try-to-close-not-opened-dir-fd.patch

5f7b57
From 1d6bd3cb4b06c8075ade1807f383667db670f2d1 Mon Sep 17 00:00:00 2001
5f7b57
From: Jakub Filak <jfilak@redhat.com>
5f7b57
Date: Tue, 5 May 2015 16:21:36 +0200
5f7b57
Subject: [LIBREPORT PATCH] dd: don't try to close not opened dir fd
5f7b57
5f7b57
dd_do_open() checks if dd_fd is not negative but if it is negative the
5f7b57
function calls dd_close() which passes dd_fd to close() in any case.
5f7b57
5f7b57
This commit adds a check to dd_close() which ensures that the function
5f7b57
does not try to close negative dd_fd.
5f7b57
5f7b57
Uncovered by coverity.
5f7b57
5f7b57
Signed-off-by: Jakub Filak <jfilak@redhat.com>
5f7b57
---
5f7b57
 src/lib/dump_dir.c | 5 ++++-
5f7b57
 1 file changed, 4 insertions(+), 1 deletion(-)
5f7b57
5f7b57
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
5f7b57
index 04caa06..d9b8603 100644
5f7b57
--- a/src/lib/dump_dir.c
5f7b57
+++ b/src/lib/dump_dir.c
5f7b57
@@ -397,7 +397,10 @@ void dd_close(struct dump_dir *dd)
5f7b57
         return;
5f7b57
 
5f7b57
     dd_unlock(dd);
5f7b57
-    close(dd->dd_fd);
5f7b57
+
5f7b57
+    if (dd->dd_fd >= 0)
5f7b57
+        close(dd->dd_fd);
5f7b57
+
5f7b57
     if (dd->next_dir)
5f7b57
     {
5f7b57
         closedir(dd->next_dir);
5f7b57
-- 
5f7b57
1.8.3.1
5f7b57