Avoid assert failure when our cached-routers file is empty on startup.

(reported by revstray)


svn:r8928
This commit is contained in:
Roger Dingledine
2006-11-12 07:09:22 +00:00
parent 968b07985e
commit 3d6b97399f
2 changed files with 11 additions and 2 deletions
+4 -2
View File
@@ -7,10 +7,12 @@ Changes in version 0.1.2.4-alpha - 2006-11-??
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
+7
View File
@@ -141,6 +141,13 @@ tor_mmap_file(const char *filename)
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);