diff options
Diffstat (limited to 'src/or/eventdns.c')
-rw-r--r-- | src/or/eventdns.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/or/eventdns.c b/src/or/eventdns.c index 517db58853..0aba4dbfb9 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -2683,7 +2683,7 @@ resolv_conf_parse_line(char *const start, int flags) { int evdns_resolv_conf_parse(int flags, const char *const filename) { struct stat st; - int fd; + int fd, n, r; u8 *resolv; char *start; int err = 0; @@ -2707,10 +2707,15 @@ evdns_resolv_conf_parse(int flags, const char *const filename) { resolv = (u8 *) malloc((size_t)st.st_size + 1); if (!resolv) { err = 4; goto out1; } - if (read(fd, resolv, (size_t)st.st_size) != st.st_size) { - err = 5; goto out2; + n = 0; + while ((r = read(fd, resolv+n, (size_t)st.st_size-n)) > 0) { + n += r; + if (n == st.st_size) + break; + assert(n < st.st_size); } - resolv[st.st_size] = 0; // we malloced an extra byte + if (r < 0) { err = 5; goto out2; } + resolv[n] = 0; // we malloced an extra byte; this should be fine. start = (char *) resolv; for (;;) { |