diff options
author | Karsten Loesing <karsten.loesing@gmx.net> | 2009-12-18 13:29:51 +0100 |
---|---|---|
committer | Karsten Loesing <karsten.loesing@gmx.net> | 2009-12-18 13:29:51 +0100 |
commit | 3a5a728d4a5490ac24819df54aca4a7d0dde0d10 (patch) | |
tree | 8eaf775926352a1a2f8fccb767535527867e5ba1 /src/or/geoip.c | |
parent | f80672d74786c05a776fdbd8581d553c98d75e5a (diff) | |
download | tor-3a5a728d4a5490ac24819df54aca4a7d0dde0d10.tar.gz tor-3a5a728d4a5490ac24819df54aca4a7d0dde0d10.zip |
Permit an empty "bridge-ips" line when parsing bridge stats.
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r-- | src/or/geoip.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c index d99e472118..45dc8cf344 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -1102,6 +1102,7 @@ parse_bridge_stats_controller(const char *stats_str, time_t now) const char *BRIDGE_STATS_END = "bridge-stats-end "; const char *BRIDGE_IPS = "bridge-ips "; + const char *BRIDGE_IPS_EMPTY_LINE = "bridge-ips\n"; const char *tmp; time_t stats_end_time; size_t controller_len; @@ -1130,17 +1131,21 @@ parse_bridge_stats_controller(const char *stats_str, time_t now) /* Parse: "bridge-ips CC=N,CC=N,..." */ tmp = find_str_at_start_of_line(stats_str, BRIDGE_IPS); - if (!tmp) - return NULL; - tmp += strlen(BRIDGE_IPS); - - tmp = eat_whitespace_no_nl(tmp); - - eol = strchr(tmp, '\n'); - if (eol) - summary = tor_strndup(tmp, eol-tmp); - else - summary = tor_strdup(tmp); + if (tmp) { + tmp += strlen(BRIDGE_IPS); + tmp = eat_whitespace_no_nl(tmp); + eol = strchr(tmp, '\n'); + if (eol) + summary = tor_strndup(tmp, eol-tmp); + else + summary = tor_strdup(tmp); + } else { + /* Look if there is an empty "bridge-ips" line */ + tmp = find_str_at_start_of_line(stats_str, BRIDGE_IPS_EMPTY_LINE); + if (!tmp) + return NULL; + summary = tor_strdup(""); + } controller_len = strlen("TimeStarted=\"\" CountrySummary=") + strlen(summary) + 42; |