From 9e3608ce7b2c3178bb2781e32c8bdc320527664b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 14 Dec 2003 04:18:43 +0000 Subject: [PATCH] more friendly warning when a connection buffer overflows svn:r918 --- src/or/buffers.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/or/buffers.c b/src/or/buffers.c index 0cfaae5c96..2ca05a0fce 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -208,13 +208,13 @@ int read_to_buf_tls(tor_tls *tls, int at_most, buf_t *buf) { if (buf_ensure_capacity(buf, at_most+buf->datalen)) return -1; - + if (at_most > buf->len - buf->datalen) at_most = buf->len - buf->datalen; if (at_most == 0) return 0; - + r = tor_tls_read(tls, buf->mem+buf->datalen, at_most); if (r<0) return r; @@ -291,15 +291,9 @@ int write_to_buf(const char *string, int string_len, buf_t *buf) { assert(string && BUF_OK(buf)); if (buf_ensure_capacity(buf, buf->datalen+string_len)) + log_fn(LOG_WARN, "buflen too small, can't hold %d bytes.",buf->datalen+string_len); return -1; - /* this is the point where you would grow the buffer, if you want to */ - - if (string_len + buf->datalen > buf->len) { /* we're out of luck */ - log_fn(LOG_WARN, "buflen too small. Time to implement growing dynamic bufs."); - return -1; - } - memcpy(buf->mem+buf->datalen, string, string_len); buf->datalen += string_len; log_fn(LOG_DEBUG,"added %d bytes to buf (now %d total).",string_len, (int)buf->datalen); -- 2.11.4.GIT