diff options
author | Roger Dingledine <arma@torproject.org> | 2003-09-25 10:42:07 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-09-25 10:42:07 +0000 |
commit | 3b5191d36dd62af1a7c6e08ce3a171d189870b64 (patch) | |
tree | 8852c3a4b57e7c464e656c6a278bfe2fd2f5d862 /src/or/buffers.c | |
parent | 3d4ccb781ae5d74f0e16a63c89e08459d15cccf1 (diff) | |
download | tor-3b5191d36dd62af1a7c6e08ce3a171d189870b64.tar.gz tor-3b5191d36dd62af1a7c6e08ce3a171d189870b64.zip |
various bugfixes and updates
redo all the config files for the new format (we'll redo them again soon)
fix (another! yuck) segfault in log_fn when input is too large
tor_tls_context_new() returns -1 for error, not NULL
fix segfault in check_conn_marked() on conn's that die during tls handshake
make ORs also initialize conn from router when we're the receiving node
make non-dirserver ORs upload descriptor to every dirserver on startup
add our local address to the descriptor
add Content-Length field to POST command
revert the Content-Length search in fetch_from_buf_http() to previous code
fix segfault in memmove in fetch_from_buf_http()
raise maximum allowed headers/body size in directory.c
svn:r484
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 3119fec5ad..6dd7185271 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -38,6 +38,10 @@ static int find_str_in_str(const char *str, int str_len, return -1; } +int find_on_inbuf(char *string, int string_len, buf_t *buf) { + return find_str_in_str(string, string_len, buf->buf, buf->datalen); +} + /* Create and return a new buf of size 'size' */ buf_t *buf_new_with_capacity(size_t size) { @@ -206,7 +210,7 @@ int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen) return r; } -int write_to_buf(char *string, int string_len, buf_t *buf) { +int write_to_buf(const char *string, int string_len, buf_t *buf) { /* append string to buf (growing as needed, return -1 if "too big") * return total number of bytes on the buf @@ -285,11 +289,12 @@ int fetch_from_buf_http(buf_t *buf, } #define CONTENT_LENGTH "\r\nContent-Length: " - i = find_str_in_str(CONTENT_LENGTH, sizeof(CONTENT_LENGTH), + i = find_str_in_str(CONTENT_LENGTH, strlen(CONTENT_LENGTH), headers, headerlen); if(i > 0) { contentlen = atoi(headers+i); /* XXX What if content-length is malformed? */ + log_fn(LOG_DEBUG,"Got a contentlen of %d.",contentlen); if(bodylen < contentlen) { log_fn(LOG_DEBUG,"body not all here yet."); return 0; /* not all there yet */ @@ -307,7 +312,7 @@ int fetch_from_buf_http(buf_t *buf, body_out[bodylen] = 0; /* null terminate it */ } buf->datalen -= (headerlen+bodylen); - memmove(buf, buf->buf+headerlen+bodylen, buf->datalen); + memmove(buf->buf, buf->buf+headerlen+bodylen, buf->datalen); return 1; } @@ -401,15 +406,6 @@ int fetch_from_buf_socks(buf_t *buf, return 1; } -int find_on_inbuf(char *string, int string_len, buf_t *buf) { - /* find first instance of needle 'string' on haystack 'buf'. return how - * many bytes from the beginning of buf to the end of string. - * If it's not there, return -1. - */ - - return find_str_in_str(string, string_len, buf->buf, buf->datalen); -} - /* Local Variables: mode:c |