diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-05-21 21:48:02 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-05-21 21:48:02 +0000 |
commit | de5194eeaad226bee702fbe5170bde2c476933dd (patch) | |
tree | b4a4f8c495c47200ff0e86e16bef96001461ce91 /src/or/eventdns.c | |
parent | 60c2dced989fefdb8447b068d86dea70d24b2962 (diff) | |
download | tor-de5194eeaad226bee702fbe5170bde2c476933dd.tar.gz tor-de5194eeaad226bee702fbe5170bde2c476933dd.zip |
r13025@Kushana: nickm | 2007-05-21 17:40:56 -0400
Bugfix and possible backport candidate: use the same logic as in read_all when reading resolv.conf. Maybe this fixes bug 433.
svn:r10237
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 fb267babc7..48db73d7ce 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -2691,7 +2691,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; @@ -2715,10 +2715,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 (;;) { |