[or-cvs] make it work correctly when we download multiple network-st...

Nick Mathewson nickm at seul.org
Thu Sep 8 21:28:47 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv23042/src/or

Modified Files:
	directory.c 
Log Message:
make it work correctly when we download multiple network-status objects.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.264
retrieving revision 1.265
diff -u -d -r1.264 -r1.265
--- directory.c	8 Sep 2005 21:01:24 -0000	1.264
+++ directory.c	8 Sep 2005 21:28:45 -0000	1.265
@@ -889,6 +889,7 @@
 
   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 @@
       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;
     }



More information about the tor-commits mailing list