diff --git a/ChangeLog b/ChangeLog index a08ea9ae7e..159a8a5092 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/common/compat.c b/src/common/compat.c index e07d3a3695..db38e757e3 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -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);