]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid assertion on read_file_to_str() with size==SIZE_T_CEILING-1
authorNick Mathewson <nickm@torproject.org>
Mon, 3 Jan 2011 20:30:11 +0000 (15:30 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 3 Jan 2011 20:30:11 +0000 (15:30 -0500)
Spotted by doors, fixes bug 2326.

changes/bug2326 [new file with mode: 0644]
src/common/util.c

diff --git a/changes/bug2326 b/changes/bug2326
new file mode 100644 (file)
index 0000000..239a383
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes
+    - Fix a bug where we would assert if we ever had a
+      cached-descriptors.new file (or another file read directly into
+      memory) of exactly SIZE_T_CEILING bytes.  Found by doors; fixes
+      bug 2326; bugfix on 0.2.1.25.
+
index 7a24df813308d6a70b50a832bbfeb1187d9e9c7a..f206d00c49509277af58082e557467f43d0e85cc 100644 (file)
@@ -1936,7 +1936,7 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out)
     return NULL;
   }
 
-  if ((uint64_t)(statbuf.st_size)+1 > SIZE_T_CEILING)
+  if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING)
     return NULL;
 
   string = tor_malloc((size_t)(statbuf.st_size+1));