Commit 9e3608ce authored by Roger Dingledine's avatar Roger Dingledine
Browse files

more friendly warning when a connection buffer overflows


svn:r918
parent a1745b68
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -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);