diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-06-17 20:37:21 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-06-17 20:37:21 +0000 |
commit | 9b4aa8d2abbce71398e58188209a1b1d04885b96 (patch) | |
tree | 88b16790cf8134537f3d388b4d98569eda7ee880 /src/or/buffers.c | |
parent | 53ea9e54e7cbb0c303c915fb121b4c8a5efed73e (diff) | |
download | tor-9b4aa8d2abbce71398e58188209a1b1d04885b96.tar tor-9b4aa8d2abbce71398e58188209a1b1d04885b96.tar.gz |
Implement all the easy bits of the new control protocol
svn:r4449
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 4c813eb2e..7b8f919cc 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -1198,19 +1198,20 @@ fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len) char *eol; size_t sz; /* Look for a CRLF. */ - if (!(eol = find_crlf_on_buf(buf, buf->cur))) + if (!(eol = find_crlf_on_buf(buf, buf->cur))) { return 0; + } sz = _buf_offset(buf, eol); - if (sz+2 > *data_len) { - *data_len = sz+2; + if (sz+3 > *data_len) { + *data_len = sz+3; return -1; } fetch_from_buf(data_out, sz+2, buf); + data_out[sz+2] = '\0'; *data_len = sz+2; return 1; } - /** Log an error and exit if <b>buf</b> is corrupted. */ void assert_buf_ok(buf_t *buf) |