Add an assertion to read_file_to_str_until_eof

The clangalyzer doesn't believe our math here.  I'm pretty sure our
math is right.  Also, add some unit tests.
This commit is contained in:
Nick Mathewson
2014-09-02 13:29:11 -04:00
parent 1a2f2c163f
commit 07a16b3372
2 changed files with 26 additions and 0 deletions
+1
View File
@@ -2357,6 +2357,7 @@ read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out)
pos += r;
} while (r > 0 && pos < max_bytes_to_read);
tor_assert(pos < string_max);
*sz_out = pos;
string[pos] = '\0';
return string;