aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2008-02-13 07:25:27 +0000
committerRoger Dingledine <arma@torproject.org>2008-02-13 07:25:27 +0000
commit27227679b488c8040834ca7196f85c899b914cd4 (patch)
tree3d270bb1213ff0a65f520d48f56364e752668060
parentc3bd8d144c56aaffcbd568be47031539b5698d1f (diff)
downloadtor-27227679b488c8040834ca7196f85c899b914cd4.tar.gz
tor-27227679b488c8040834ca7196f85c899b914cd4.zip
backport r13488
svn:r13489
-rw-r--r--ChangeLog2
-rw-r--r--src/common/compat.c5
2 files changed, 4 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 99f1b2acea..e4a7887b95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@ Changes in versino 0.1.2.20 - 2008-??-??
Resolves bug 597.
- Fix a few memory leaks that could in theory happen under bizarre error
conditions.
+ - We were leaking a file descriptor if Tor started with a zero-length
+ cached-descriptors file. Patch by freddy77.
Changes in version 0.1.2.19 - 2008-01-17
diff --git a/src/common/compat.c b/src/common/compat.c
index 71ac5d5e04..013956446e 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -158,19 +158,18 @@ tor_mmap_file(const char *filename)
/* Zero-length file. If we call mmap on it, it will succeed but
* return NULL, and bad things will happen. So just fail. */
log_info(LD_FS,"File \"%s\" is empty. Ignoring.",filename);
+ close(fd);
return NULL;
}
string = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0);
+ close(fd);
if (string == MAP_FAILED) {
- close(fd);
log_warn(LD_FS,"Could not mmap file \"%s\": %s", filename,
strerror(errno));
return NULL;
}
- close(fd);
-
res = tor_malloc_zero(sizeof(tor_mmap_impl_t));
res->base.data = string;
res->base.size = filesize;