diff options
author | Yang Tse <yangsita@gmail.com> | 2010-02-26 16:42:33 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-02-26 16:42:33 +0000 |
commit | bcd1c7c2e92d41ab02163a36a1ab9d5a7afd83a9 (patch) | |
tree | 0b98ca5c331ee57703a51747d0f8e975ceaffab7 /ares/ares__read_line.c | |
parent | 87428e07ca17a99fb2409ec39213b7badbe967ea (diff) |
fix compiler warning
Diffstat (limited to 'ares/ares__read_line.c')
-rw-r--r-- | ares/ares__read_line.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ares/ares__read_line.c b/ares/ares__read_line.c index 29f8e5dc0..2e94945dc 100644 --- a/ares/ares__read_line.c +++ b/ares/ares__read_line.c @@ -20,6 +20,7 @@ #include <stdlib.h> #include <string.h> #include "ares.h" +#include "ares_nowarn.h" #include "ares_private.h" /* This is an internal function. Its contract is to read a line from @@ -46,7 +47,9 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) for (;;) { - if (!fgets(*buf + offset, (int)(*bufsize - offset), fp)) + int bytestoread = aresx_uztosi(*bufsize - offset); + + if (!fgets(*buf + offset, bytestoread, fp)) return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF; len = offset + strlen(*buf + offset); if ((*buf)[len - 1] == '\n') @@ -55,6 +58,8 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) break; } offset = len; + if(len < *bufsize - 1) + continue; /* Allocate more space. */ newbuf = realloc(*buf, *bufsize * 2); |