aboutsummaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-10-14 02:26:13 +0000
committerNick Mathewson <nickm@torproject.org>2005-10-14 02:26:13 +0000
commit998cf8d6222607113fbd8fa8563d507a808ee869 (patch)
tree2e3f8dfbf46c60a659b75f715a65b8266f5377a0 /src/or/directory.c
parent11b76b9ca5b39eeeb4fcff1593db2efe14cc5827 (diff)
downloadtor-998cf8d6222607113fbd8fa8563d507a808ee869.tar
tor-998cf8d6222607113fbd8fa8563d507a808ee869.tar.gz
Try to extract as many descriptors as possible from truncated http responses. (when DIR_PURPOSE_FETCH_ROUTERDESC)
svn:r5249
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index feb6766c8..89ef3b630 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -806,10 +806,12 @@ connection_dir_client_reached_eof(connection_t *conn)
int compression;
int plausible;
int skewed=0;
+ int allow_partial = conn->purpose == DIR_PURPOSE_FETCH_SERVERDESC;
switch (fetch_from_buf_http(conn->inbuf,
&headers, MAX_HEADERS_SIZE,
- &body, &body_len, MAX_DIR_SIZE)) {
+ &body, &body_len, MAX_DIR_SIZE,
+ allow_partial)) {
case -1: /* overflow */
log_fn(LOG_WARN,"'fetch' response too large (server '%s:%d'). Closing.", conn->address, conn->port);
return -1;
@@ -878,11 +880,13 @@ connection_dir_client_reached_eof(connection_t *conn)
}
/* Try declared compression first if we can. */
if (compression > 0)
- tor_gzip_uncompress(&new_body, &new_len, body, body_len, compression, 1);
+ tor_gzip_uncompress(&new_body, &new_len, body, body_len, compression,
+ allow_partial);
/* Okay, if that didn't work, and we think that it was compressed
* differently, try that. */
if (!new_body && guessed > 0 && compression != guessed)
- tor_gzip_uncompress(&new_body, &new_len, body, body_len, guessed, 1);
+ tor_gzip_uncompress(&new_body, &new_len, body, body_len, guessed,
+ allow_partial);
/* If we're pretty sure that we have a compressed directory, and
* we didn't manage to uncompress it, then warn and bail. */
if (!plausible && !new_body) {
@@ -1510,7 +1514,7 @@ directory_handle_command(connection_t *conn)
switch (fetch_from_buf_http(conn->inbuf,
&headers, MAX_HEADERS_SIZE,
- &body, &body_len, MAX_BODY_SIZE)) {
+ &body, &body_len, MAX_BODY_SIZE, 0)) {
case -1: /* overflow */
log_fn(LOG_WARN,"Invalid input from address '%s'. Closing.", conn->address);
return -1;