[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] better way: always nul-terminate. then sometimes use it, so...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] better way: always nul-terminate. then sometimes use it, so...
- From: arma@seul.org (Roger Dingledine)
- Date: Wed, 31 Mar 2004 00:10:36 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Wed, 31 Mar 2004 00:10:54 -0500
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
buffers.c directory.c
Log Message:
better way: always nul-terminate. then sometimes use it, sometimes not.
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- buffers.c 31 Mar 2004 05:01:30 -0000 1.74
+++ buffers.c 31 Mar 2004 05:10:34 -0000 1.75
@@ -332,8 +332,7 @@
* the body are present, or b) there's no Content-Length field and
* all headers are present, then:
* strdup headers into *headers_out, and nul-terminate it.
- * memdup body into *body_out, and malloc one byte more than
- * necessary, in case the caller wants to nul-terminate it.
+ * memdup body into *body_out, and nul-terminate it.
* Then remove them from buf, and return 1.
*
* If headers or body is NULL, discard that part of the buf.
@@ -395,7 +394,7 @@
*body_used = bodylen;
*body_out = tor_malloc(bodylen+1);
memcpy(*body_out,buf->mem+headerlen,bodylen);
- /* don't null terminate it */
+ (*body_out)[bodylen] = 0; /* null terminate it */
}
buf_remove_from_front(buf, headerlen+bodylen);
return 1;
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- directory.c 31 Mar 2004 05:01:30 -0000 1.75
+++ directory.c 31 Mar 2004 05:10:34 -0000 1.76
@@ -211,8 +211,6 @@
if(conn->purpose == DIR_PURPOSE_FETCH_DIR) {
/* fetch/process the directory to learn about new routers. */
- directory[dir_len] = 0; /* null terminate it, we can do this
- because fetch_from_buf_http made space */
log_fn(LOG_INFO,"Received directory (size %d):\n%s", dir_len, directory);
if(status_code == 503 || dir_len == 0) {
log_fn(LOG_INFO,"Empty directory. Ignoring.");
@@ -374,7 +372,6 @@
}
if(!strcmp(url,"/")) { /* server descriptor post */
- body[body_len] = 0; /* dirserv_add_descriptor expects nul-terminated */
cp = body;
switch(dirserv_add_descriptor(&cp)) {
case -1: