Two consensus fixes: always reset has_* to 0, and use a buffer of proper length for exitsummaries.

svn:r16575
This commit is contained in:
Peter Palfrader 2008-08-17 08:01:23 +00:00
parent 4eecd27b42
commit 3c0b0ccca9

View File

@ -878,6 +878,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
rs_out.published_on = rs->status.published_on; rs_out.published_on = rs->status.published_on;
rs_out.dir_port = rs->status.dir_port; rs_out.dir_port = rs->status.dir_port;
rs_out.or_port = rs->status.or_port; rs_out.or_port = rs->status.or_port;
rs_out.has_bandwidth = 0;
rs_out.has_exitsummary = 0;
if (chosen_name && !naming_conflict) { if (chosen_name && !naming_conflict) {
strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname)); strlcpy(rs_out.nickname, chosen_name, sizeof(rs_out.nickname));
@ -1046,6 +1048,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
}; };
/* Now the exitpolicy summary line. */ /* Now the exitpolicy summary line. */
if (rs_out.has_exitsummary) { if (rs_out.has_exitsummary) {
char buf[MAX_POLICY_LINE_LEN+1];
int r = tor_snprintf(buf, sizeof(buf), "p %s\n", rs_out.exitsummary); int r = tor_snprintf(buf, sizeof(buf), "p %s\n", rs_out.exitsummary);
if (r<0) { if (r<0) {
log_warn(LD_BUG, "Not enough space in buffer for exitpolicy line."); log_warn(LD_BUG, "Not enough space in buffer for exitpolicy line.");