summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-09-08 20:36:40 +0000
committerNick Mathewson <nickm@torproject.org>2005-09-08 20:36:40 +0000
commit18e4d7835484924d6d26685dd890012058434472 (patch)
tree4a5fc68f030c7cfd8f0f32d2348f1e6c41b4f273 /src/or/directory.c
parent059148f5880de62e29ec63f5ca17cecc5767dfa1 (diff)
downloadtor-18e4d7835484924d6d26685dd890012058434472.tar.gz
tor-18e4d7835484924d6d26685dd890012058434472.zip
Fix an assert in directory.c. Check received network-status objects against the list we expected to get. Do not let anyone else update our network-status object.
svn:r4945
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 2b13cbae86..74167694b9 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -401,7 +401,8 @@ directory_send_command(connection_t *conn, const char *platform,
tor_assert(conn->type == CONN_TYPE_DIR);
tor_free(conn->requested_resource);
- conn->requested_resource = tor_strdup(resource);
+ if (resource)
+ conn->requested_resource = tor_strdup(resource);
/* come up with a string for which Host: we want */
if (conn->port == 80) {
@@ -450,13 +451,13 @@ directory_send_command(connection_t *conn, const char *platform,
url = tor_strdup("/tor/running-routers");
break;
case DIR_PURPOSE_FETCH_NETWORKSTATUS:
- httpcommand = "GET";//XXXX
+ httpcommand = "GET";
len = strlen(resource)+32;
url = tor_malloc(len);
tor_snprintf(url, len, "/tor/status/%s", resource);
break;
case DIR_PURPOSE_FETCH_SERVERDESC:
- httpcommand = "GET";//XXXX
+ httpcommand = "GET";
len = strlen(resource)+32;
url = tor_malloc(len);
tor_snprintf(url, len, "/tor/server/%s", resource);
@@ -887,9 +888,7 @@ connection_dir_client_reached_eof(connection_t *conn)
}
if (conn->purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
- /* XXXX NM We *must* make certain we get the one(s) we asked for or we
- * could be partitioned. Also, never ask someone else for a status we
- * generated! */
+ smartlist_t *which = NULL;
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.",
@@ -897,17 +896,26 @@ connection_dir_client_reached_eof(connection_t *conn)
tor_free(body); tor_free(headers); tor_free(reason);
return -1;
}
+ if (conn->requested_resource &&
+ !strcmpstart(conn->requested_resource,"fp/")) {
+ which = smartlist_create();
+ smartlist_split_string(which, conn->requested_resource+3, "+", 0, -1);
+ }
while (*body) {
char *next = strstr(body, "\nnetwork-status-version");
if (next)
*next = '\0';
- if (router_set_networkstatus(body, time(NULL), 0)<0)
+ if (router_set_networkstatus(body, time(NULL), NS_FROM_DIR, which)<0)
break;
if (next)
body = next+1;
else
break;
}
+ if (which) {
+ SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
+ smartlist_free(which);
+ }
}
if (conn->purpose == DIR_PURPOSE_FETCH_SERVERDESC) {