From 9df4716ac354ade52f02cca8ae479fbc93eeb985 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 8 Sep 2005 21:28:45 +0000 Subject: make it work correctly when we download multiple network-status objects. svn:r4952 --- src/or/directory.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/or/directory.c b/src/or/directory.c index 7f65c13f82..e3ae92cd71 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -889,6 +889,7 @@ connection_dir_client_reached_eof(connection_t *conn) if (conn->purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) { smartlist_t *which = NULL; + char *cp; log_fn(LOG_INFO,"Received networkstatus objects (size %d) from server '%s:%d'",(int) body_len, conn->address, conn->port); if (status_code != 200) { log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s:%d'. Failing.", @@ -901,14 +902,17 @@ connection_dir_client_reached_eof(connection_t *conn) which = smartlist_create(); smartlist_split_string(which, conn->requested_resource+3, "+", 0, -1); } - while (*body) { - char *next = strstr(body, "\nnetwork-status-version"); + cp = body; + while (*cp) { + char *next = strstr(cp, "\nnetwork-status-version"); if (next) - *next = '\0'; - if (router_set_networkstatus(body, time(NULL), NS_FROM_DIR, which)<0) + next[1] = '\0'; + if (router_set_networkstatus(cp, time(NULL), NS_FROM_DIR, which)<0) break; - if (next) - body = next+1; + if (next) { + next[1] = 'n'; + cp = next+1; + } else break; } -- cgit v1.2.3-54-g00ecf