You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
1003 B

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