[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Note a non-bug in read_file_to_str as used. If we start to ...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Note a non-bug in read_file_to_str as used. If we start to ...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Tue, 22 Feb 2005 02:18:49 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 22 Feb 2005 02:19:08 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv16163/src/common
Modified Files:
util.c
Log Message:
Note a non-bug in read_file_to_str as used. If we start to rely on it behaving differently, we need to change how it behaves. [Noticed by Chris Palmer]
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -d -r1.201 -r1.202
--- util.c 22 Feb 2005 07:03:03 -0000 1.201
+++ util.c 22 Feb 2005 07:18:46 -0000 1.202
@@ -880,8 +880,15 @@
return -1;
}
-/** Read the contents of <b>filename</b> into a newly allocated string; return the
- * string on success or NULL on failure.
+/** Read the contents of <b>filename</b> into a newly allocated
+ * string; return the string on success or NULL on failure.
+ */
+/*
+ * This function <em>may</em> return an erroneous result if the file
+ * is modified while it is running, but must not crash or overflow.
+ * Right now, the error case occurs when the file length grows between
+ * the call to stat and the call to read_all: the resulting string will
+ * be truncated.
*/
char *read_file_to_str(const char *filename, int bin) {
int fd; /* router file */