]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
fix two new segfaults
authorRoger Dingledine <arma@torproject.org>
Sun, 28 Sep 2003 08:06:18 +0000 (08:06 +0000)
committerRoger Dingledine <arma@torproject.org>
Sun, 28 Sep 2003 08:06:18 +0000 (08:06 +0000)
svn:r506

src/or/directory.c
src/or/dirserv.c
src/or/main.c

index 562326d6a016338a40ca43a8f495b93852efb6c8..804ad699972c2a87ee92ac3b9d321198fa345921 100644 (file)
@@ -167,7 +167,7 @@ int connection_dir_process_inbuf(connection_t *conn) {
 static int directory_handle_command(connection_t *conn) {
   char headers[1024];
   char body[50000]; /* XXX */
-  size_t dl;
+  size_t dlen;
   const char *cp;
 
   assert(conn && conn->type == CONN_TYPE_DIR);
@@ -187,16 +187,16 @@ static int directory_handle_command(connection_t *conn) {
   if(!strncasecmp(headers,"GET",3)) {
     /* XXX should check url and http version */
 
-    dl = dirserv_get_directory(&cp);
+    dlen = dirserv_get_directory(&cp);
 
-    if(dl == 0) {
+    if(dlen == 0) {
       log_fn(LOG_WARNING,"My directory is empty. Closing.");
       return -1;
     }
 
     log_fn(LOG_DEBUG,"Dumping directory to client."); 
     if((connection_write_to_buf(answerstring, strlen(answerstring), conn) < 0) ||
-       (connection_write_to_buf(cp, dl, conn) < 0)) {
+       (connection_write_to_buf(cp, dlen, conn) < 0)) {
       log_fn(LOG_WARNING,"Failed to write answerstring+directory to outbuf.");
       return -1;
     }
index 901d2e9456d6ad5953aed4314922696f79b2312b..a6ff12d8a02b0e8adc9ee70b55163161c65706cd 100644 (file)
@@ -373,7 +373,7 @@ size_t dirserv_get_directory(const char **directory)
     /* Now read the directory we just made in order to update our own
      * router lists.  This does more signature checking than is strictly
      * necessary, but safe is better than sorry. */
-    new_directory = strdup(*directory);
+    new_directory = strdup(the_directory);
     if (router_get_dir_from_string(new_directory, get_identity_key())) {
       log_fn(LOG_ERR, "We just generated a directory we can't parse. Dying.");
       exit(0);
index 9f861b96cc75cb0dd031ff96e7a2a432508b7afa..83f10ee19bd6e5446b69d38e6ab82bc07752b8f7 100644 (file)
@@ -836,16 +836,14 @@ list_running_servers(char **nicknames_out)
     length += strlen(nickname_lst[i]);
   }
   *nicknames_out = tor_malloc(length);
-  log_fn(LOG_DEBUG,"total length %d malloced.",length);
   cp = *nicknames_out;
+  memset(cp,0,length);
   for (i = 0; i<n; ++i) {
     if (i)
       strcat(cp, " ");
     strcat(cp, nickname_lst[i]);
     while (*cp) 
       ++cp;
-    log_fn(LOG_DEBUG,"end of loop %d, now %d written (nick %s)",
-           i,1+(int)(cp-*nicknames_out),nickname_lst[i]);
   }
   return 0;
 }