[or-cvs] Add belt-and-suspenders fix to coredump from yesterday; doc...

Nick Mathewson nickm at seul.org
Tue Jul 12 18:19:32 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv25911/src/or

Modified Files:
	buffers.c 
Log Message:
Add belt-and-suspenders fix to coredump from yesterday; document more functions in buffers.c

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- buffers.c	12 Jul 2005 05:48:15 -0000	1.166
+++ buffers.c	12 Jul 2005 18:19:30 -0000	1.167
@@ -1105,6 +1105,9 @@
   tor_assert(type_out);
   tor_assert(body_out);
 
+  *len_out = 0;
+  *body_out = NULL;
+
   if (buf->datalen < 4)
     return 0;
 
@@ -1125,13 +1128,13 @@
     *body_out = tor_malloc(msglen+1);
     fetch_from_buf(*body_out, msglen, buf);
     (*body_out)[msglen] = '\0';
-  } else {
-    *body_out = NULL;
   }
   return 1;
 }
 
-/** DOCDOC */
+/** Helper: return a pointer to the first instance of <b>c</b> in the
+ * <b>len</b>characters after <b>start</b> on <b>buf</b>. Return NULL if the
+ * character isn't found. */
 static char *
 find_char_on_buf(buf_t *buf, char *start, size_t len, char c)
 {
@@ -1144,6 +1147,8 @@
   return memchr(buf->mem, c, len_rest);
 }
 
+/** Helper: return a pointer to the first CRLF after cp on <b>buf</b>. Return
+ * NULL if no CRLF is found. */
 static char *
 find_crlf_on_buf(buf_t *buf, char *cp)
 {
@@ -1162,7 +1167,12 @@
   }
 }
 
-/* DOCDOC : 0 means 'need to read more'. means done, -1 means "grow buffer." */
+/** Try to read a single CRLF-terminated line from <b>buf</b>, and write it,
+ * NUL-terminated, into the *<b>data_len</b> byte buffer at <b>data_out</b>.
+ * Set *<b>data_len</b> to the number of bytes in the line, not counting the
+ * terminating NUL.  Return 1 if we read a whole line, return 0 if we don't
+ * have a whole line yet, and return -1 if we we need to grow the buffer.
+ */
 int
 fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len)
 {



More information about the tor-commits mailing list