mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user