Found by Coverity. We check return value of closedir() on other places
in the code, but here we don't.
https://fedorahosted.org/sssd/ticket/1791
Patch attached.
Thanks
Michal
>From eddbd2a23a45f032c466b81b1dd5669e16d4e423 Mon Sep 17 00:00:00 2001
From: Michal Zidek <[email protected]>
Date: Fri, 25 Jan 2013 16:41:07 +0100
Subject: [PATCH] Unchecked return value in files.c
Found by coverity.
https://fedorahosted.org/sssd/ticket/1791
---
src/tools/files.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/tools/files.c b/src/tools/files.c
index 4a6625e..a550db0 100644
--- a/src/tools/files.c
+++ b/src/tools/files.c
@@ -583,6 +583,7 @@ copy_dir(struct copy_ctx *cctx,
const struct stat *src_dir_stat)
{
errno_t ret;
+ errno_t dret;
int dest_dir_fd = -1;
DIR *dir = NULL;
struct dirent *ent;
@@ -675,7 +676,14 @@ copy_dir(struct copy_ctx *cctx,
ret = EOK;
done:
- if (dir) closedir(dir);
+ if (dir) {
+ dret = closedir(dir);
+ if (dret != 0) {
+ dret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ ("Failed to close directory: %s.\n", strerror(ret)));
+ }
+ }
if (dest_dir_fd != -1) {
close(dest_dir_fd);
--
1.7.11.2
_______________________________________________
sssd-devel mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel