[tor/master] Merge remote-tracking branch 'public/bug7816_023'

commit ba7d93db16fd53c951b6a159adeb7b4094817c11 Merge: 0061d42 d3aabf4d Author: Nick Mathewson <nickm@torproject.org> Date: Thu Feb 7 15:20:50 2013 -0500 Merge remote-tracking branch 'public/bug7816_023' Conflicts: src/common/util.c changes/bug7816_023 | 7 +++++++ changes/bug7816_023_small | 3 +++ src/common/log.c | 4 +++- src/common/util.c | 4 +++- src/or/connection.c | 4 ++++ src/or/control.c | 2 ++ src/or/geoip.c | 5 ++++- 7 files changed, 26 insertions(+), 3 deletions(-) diff --cc src/common/util.c index 7d72a89,29aa83e..93e2ba8 --- a/src/common/util.c +++ b/src/common/util.c @@@ -2358,24 -2305,10 +2358,26 @@@ read_file_to_str(const char *filename, return NULL; } +#ifndef _WIN32 +/** When we detect that we're reading from a FIFO, don't read more than + * this many bytes. It's insane overkill for most uses. */ +#define FIFO_READ_MAX (1024*1024) + if (S_ISFIFO(statbuf.st_mode)) { + size_t sz = 0; + string = read_file_to_str_until_eof(fd, FIFO_READ_MAX, &sz); + if (string && stat_out) { + statbuf.st_size = sz; + memcpy(stat_out, &statbuf, sizeof(struct stat)); + } + close(fd); + return string; + } +#endif + - if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) + if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) { + close(fd); return NULL; + } string = tor_malloc((size_t)(statbuf.st_size+1));
participants (1)
-
nickm@torproject.org