[or-cvs] fix two new segfaults
Roger Dingledine
arma at seul.org
Sun Sep 28 08:07:04 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
directory.c dirserv.c main.c
Log Message:
fix two new segfaults
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- directory.c 27 Sep 2003 21:30:10 -0000 1.36
+++ directory.c 28 Sep 2003 08:06:18 -0000 1.37
@@ -167,7 +167,7 @@
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 @@
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: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dirserv.c 27 Sep 2003 21:30:10 -0000 1.1
+++ dirserv.c 28 Sep 2003 08:06:18 -0000 1.2
@@ -373,7 +373,7 @@
/* 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: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- main.c 28 Sep 2003 06:48:20 -0000 1.109
+++ main.c 28 Sep 2003 08:06:18 -0000 1.110
@@ -836,16 +836,14 @@
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;
}
More information about the tor-commits
mailing list