Skip to content

Commit

Permalink
Merge branch 'maint-0.2.9' into maint-0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed May 2, 2018
2 parents bb35405 + d465bd2 commit 993e314
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changes/bug26007
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
o Major bugfixes (directory authorities, security):
- When directory authorities read a zero-byte bandwidth file, they log
a warning with the contents of an uninitialised buffer. Log a warning
about the empty file instead.
Fixes bug 26007; bugfix on 0.2.2.1-alpha.
13 changes: 11 additions & 2 deletions src/or/dirserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2781,14 +2781,23 @@ dirserv_read_measured_bandwidths(const char *from_file,
time_t file_time, now;
int ok;

/* Initialise line, so that we can't possibly run off the end. */
memset(line, 0, sizeof(line));

if (fp == NULL) {
log_warn(LD_CONFIG, "Can't open bandwidth file at configured location: %s",
from_file);
return -1;
}

if (!fgets(line, sizeof(line), fp)
|| !strlen(line) || line[strlen(line)-1] != '\n') {
/* If fgets fails, line is either unmodified, or indeterminate. */
if (!fgets(line, sizeof(line), fp)) {
log_warn(LD_DIRSERV, "Empty bandwidth file");
fclose(fp);
return -1;
}

if (!strlen(line) || line[strlen(line)-1] != '\n') {
log_warn(LD_DIRSERV, "Long or truncated time in bandwidth file: %s",
escaped(line));
fclose(fp);
Expand Down

0 comments on commit 993e314

Please sign in to comment.