From: Nick Mathewson Date: Thu, 7 Feb 2013 20:20:50 +0000 (-0500) Subject: Merge remote-tracking branch 'public/bug7816_023' X-Git-Tag: tor-0.2.4.11-alpha~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba7d93db16fd53c951b6a159adeb7b4094817c11;p=thirdparty%2Ftor.git Merge remote-tracking branch 'public/bug7816_023' Conflicts: src/common/util.c --- ba7d93db16fd53c951b6a159adeb7b4094817c11 diff --cc src/common/util.c index 7d72a896f9,29aa83e5d6..93e2ba8e14 --- 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));