mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
fix two new segfaults
svn:r506
This commit is contained in:
parent
c4c66e2c7f
commit
5d31f71557
@ -167,7 +167,7 @@ int connection_dir_process_inbuf(connection_t *conn) {
|
|||||||
static int directory_handle_command(connection_t *conn) {
|
static int directory_handle_command(connection_t *conn) {
|
||||||
char headers[1024];
|
char headers[1024];
|
||||||
char body[50000]; /* XXX */
|
char body[50000]; /* XXX */
|
||||||
size_t dl;
|
size_t dlen;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
|
||||||
assert(conn && conn->type == CONN_TYPE_DIR);
|
assert(conn && conn->type == CONN_TYPE_DIR);
|
||||||
@ -187,16 +187,16 @@ static int directory_handle_command(connection_t *conn) {
|
|||||||
if(!strncasecmp(headers,"GET",3)) {
|
if(!strncasecmp(headers,"GET",3)) {
|
||||||
/* XXX should check url and http version */
|
/* 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.");
|
log_fn(LOG_WARNING,"My directory is empty. Closing.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fn(LOG_DEBUG,"Dumping directory to client.");
|
log_fn(LOG_DEBUG,"Dumping directory to client.");
|
||||||
if((connection_write_to_buf(answerstring, strlen(answerstring), conn) < 0) ||
|
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.");
|
log_fn(LOG_WARNING,"Failed to write answerstring+directory to outbuf.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -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
|
/* Now read the directory we just made in order to update our own
|
||||||
* router lists. This does more signature checking than is strictly
|
* router lists. This does more signature checking than is strictly
|
||||||
* necessary, but safe is better than sorry. */
|
* 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())) {
|
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.");
|
log_fn(LOG_ERR, "We just generated a directory we can't parse. Dying.");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -836,16 +836,14 @@ list_running_servers(char **nicknames_out)
|
|||||||
length += strlen(nickname_lst[i]);
|
length += strlen(nickname_lst[i]);
|
||||||
}
|
}
|
||||||
*nicknames_out = tor_malloc(length);
|
*nicknames_out = tor_malloc(length);
|
||||||
log_fn(LOG_DEBUG,"total length %d malloced.",length);
|
|
||||||
cp = *nicknames_out;
|
cp = *nicknames_out;
|
||||||
|
memset(cp,0,length);
|
||||||
for (i = 0; i<n; ++i) {
|
for (i = 0; i<n; ++i) {
|
||||||
if (i)
|
if (i)
|
||||||
strcat(cp, " ");
|
strcat(cp, " ");
|
||||||
strcat(cp, nickname_lst[i]);
|
strcat(cp, nickname_lst[i]);
|
||||||
while (*cp)
|
while (*cp)
|
||||||
++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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user