summaryrefslogtreecommitdiff
path: root/ares__read_line.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-26 16:42:33 (GMT)
committerYang Tse <yangsita@gmail.com>2010-02-26 16:42:33 (GMT)
commit86718e2f529e2dfb925dc5746032215ec79f8dfa (patch)
tree131188d77a464feae406ca07753f8863a7e1ad17 /ares__read_line.c
parent78414c0f3a4f7185323f13f04c8a1d5b68102b26 (diff)
downloadc-ares-86718e2f529e2dfb925dc5746032215ec79f8dfa.zip
c-ares-86718e2f529e2dfb925dc5746032215ec79f8dfa.tar.gz
c-ares-86718e2f529e2dfb925dc5746032215ec79f8dfa.tar.bz2
fix compiler warning
Diffstat (limited to 'ares__read_line.c')
-rw-r--r--ares__read_line.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ares__read_line.c b/ares__read_line.c
index 29f8e5d..2e94945 100644
--- a/ares__read_line.c
+++ b/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);