summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-11-09 21:50:47 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-11-09 21:50:47 +0000
commit04424f5e89e85d77be0c613af1121fadfbd22065 (patch)
treefe9eb3c7f32167e9a5b9045ceb90e2e4b17eff0d /lib/libalpm/add.c
parent2ab57b6022d5907e1e9de68e7314a5f8bc95144a (diff)
downloadpacman-04424f5e89e85d77be0c613af1121fadfbd22065.tar.xz
fixed a file descriptor leak
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index a60b0633..689172c5 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -447,17 +447,20 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
if(nb) {
char *temp;
char *md5_local, *md5_pkg;
+ int fd;
- md5_local = MDFile(expath);
/* extract the package's version to a temporary file and md5 it */
temp = strdup("/tmp/alpm_XXXXXX");
- mkstemp(temp);
+ fd = mkstemp(temp);
if(tar_extract_file(tar, temp)) {
alpm_logaction("could not extract %s (%s)", pathname, strerror(errno));
errors++;
- FREE(md5_local);
+ unlink(temp);
+ FREE(temp);
+ close(fd);
continue;
}
+ md5_local = MDFile(expath);
md5_pkg = MDFile(temp);
/* append the new md5 hash to it's respective entry in info->backup
* (it will be the new orginal)
@@ -550,6 +553,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
FREE(md5_orig);
unlink(temp);
FREE(temp);
+ close(fd);
} else {
if(!notouch) {
_alpm_log(PM_LOG_FLOW2, "extracting %s", pathname);