[or-cvs] r8928: Avoid assert failure when our cached-routers file is empty o (in tor/trunk: . src/common)
arma at seul.org
arma at seul.org
Sun Nov 12 07:09:23 UTC 2006
Author: arma
Date: 2006-11-12 02:09:22 -0500 (Sun, 12 Nov 2006)
New Revision: 8928
Modified:
tor/trunk/ChangeLog
tor/trunk/src/common/compat.c
Log:
Avoid assert failure when our cached-routers file is empty on startup.
(reported by revstray)
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2006-11-11 18:06:12 UTC (rev 8927)
+++ tor/trunk/ChangeLog 2006-11-12 07:09:22 UTC (rev 8928)
@@ -7,10 +7,12 @@
don't recognize; it's probably just from a newer version of Tor.
- Have directory authorities allow larger amounts of drift in uptime
without replacing the server descriptor: previously, a server that
- restarted every 30 minutes could have 48 "interesting" descriptors per
- day.
+ restarted every 30 minutes could have 48 "interesting" descriptors
+ per day.
- Start linking to the Tor specification and Tor reference manual
correctly in the Windows installer.
+ - Avoid assert failure when our cached-routers file is empty on
+ startup.
Changes in version 0.1.2.3-alpha - 2006-10-29
Modified: tor/trunk/src/common/compat.c
===================================================================
--- tor/trunk/src/common/compat.c 2006-11-11 18:06:12 UTC (rev 8927)
+++ tor/trunk/src/common/compat.c 2006-11-12 07:09:22 UTC (rev 8928)
@@ -141,6 +141,13 @@
page_size = getpagesize();
size += (size%page_size) ? page_size-(size%page_size) : 0;
+ if (!size) {
+ /* zero-length file. if we call mmap on it, we'll end up setting
+ * data to NULL below, and bad things will happen. So just fail. */
+ log_notice(LD_FS,"File \"%s\" is empty. Ignoring.",filename);
+ return NULL;
+ }
+
string = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (string == MAP_FAILED) {
close(fd);
More information about the tor-commits
mailing list