commit df29c592d1249b5f1c6eb69dca6684100f1f098b
Author: Oswald Buddenhagen <[email protected]>
Date: Sat Apr 12 12:46:36 2014 +0200
close a bunch of fd leaks in error paths
found by coverity.
src/drv_maildir.c | 9 +++++++--
src/mdconvert.c | 5 ++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 46b4cb1..e751f4b 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -219,8 +219,10 @@ maildir_list_recurse( store_t *gctx, int isBox, int
*flags, const char *inbox,
const char *ent = de->d_name;
pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX -
pathLen, "%s", ent );
if (inbox && !memcmp( path, inbox, pl ) && !inbox[pl]) {
- if (maildir_list_inbox( gctx, flags ) < 0)
+ if (maildir_list_inbox( gctx, flags ) < 0) {
+ closedir( dir );
return -1;
+ }
} else {
if (*ent == '.') {
if (!isBox)
@@ -238,8 +240,10 @@ maildir_list_recurse( store_t *gctx, int isBox, int
*flags, const char *inbox,
}
}
nl = nameLen + nfsnprintf( name + nameLen,
_POSIX_PATH_MAX - nameLen, "%s", ent );
- if (maildir_list_recurse( gctx, 1, flags, inbox, path,
pl, name, nl ) < 0)
+ if (maildir_list_recurse( gctx, 1, flags, inbox, path,
pl, name, nl ) < 0) {
+ closedir( dir );
return -1;
+ }
}
}
closedir (dir);
@@ -677,6 +681,7 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
ctx->db->err( ctx->db,
ret, "Maildir error: db->get()" );
mbork:
maildir_free_scan(
msglist );
+ closedir( d );
goto bork;
}
uid = INT_MAX;
diff --git a/src/mdconvert.c b/src/mdconvert.c
index 7f6366f..da9970f 100644
--- a/src/mdconvert.c
+++ b/src/mdconvert.c
@@ -208,8 +208,10 @@ convert( const char *box, int altmap )
nfsnprintf( buf2 + bl, sizeof(buf2) - bl,
"%.*s,U=%d%s", ml, e->d_name, uid, ru );
}
if (rename( buf, buf2 )) {
- if (errno == ENOENT)
+ if (errno == ENOENT) {
+ closedir( d );
goto again;
+ }
sys_error( "Cannot rename %s to %s", buf, buf2
);
ebork:
closedir( d );
@@ -224,6 +226,7 @@ convert( const char *box, int altmap )
close( dfd );
if (rename( tdpath, dpath )) {
sys_error( "Cannot rename %s to %s", tdpath, dpath );
+ close( sfd );
return 1;
}
if (unlink( spath ))
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel