[or-cvs] handle_control_getinfo() was counting msg_len itself,

Roger Dingledine arma at seul.org
Tue Mar 22 05:41:07 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	control.c 
Log Message:
handle_control_getinfo() was counting msg_len itself,
when that's actually smartlist_join_strings2()'s job.


Index: control.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- control.c	22 Mar 2005 03:27:51 -0000	1.60
+++ control.c	22 Mar 2005 05:41:05 -0000	1.61
@@ -589,7 +589,6 @@
   smartlist_split_string(questions, body, "\n",
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   answers = smartlist_create();
-  msg_len = 0;
   SMARTLIST_FOREACH(questions, const char *, q,
   {
     if (handle_getinfo_helper(q, &ans) < 0) {
@@ -601,12 +600,12 @@
     }
     smartlist_add(answers, tor_strdup(q));
     smartlist_add(answers, ans);
-    msg_len += 2 + strlen(ans) + strlen(q);
   });
 
   msg = smartlist_join_strings2(answers, "\0", 1, 1, &msg_len);
+  tor_assert(msg_len > 0); /* it will at least be terminated */
   send_control_message(conn, CONTROL_CMD_INFOVALUE,
-                       msg_len, msg_len?msg:NULL);
+                       msg_len, msg);
 
  done:
   if (answers) SMARTLIST_FOREACH(answers, char *, cp, tor_free(cp));



More information about the tor-commits mailing list