[or-cvs] more friendly warning when a connection buffer overflows

Roger Dingledine arma at seul.org
Sun Dec 14 04:18:45 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	buffers.c 
Log Message:
more friendly warning when a connection buffer overflows


Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- buffers.c	16 Nov 2003 17:00:02 -0000	1.53
+++ buffers.c	14 Dec 2003 04:18:43 -0000	1.54
@@ -208,13 +208,13 @@
 
   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 @@
   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);



More information about the tor-commits mailing list