aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_expand_string.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-23 18:46:27 +0000
committerYang Tse <yangsita@gmail.com>2010-02-23 18:46:27 +0000
commitaa0f8593b9b97948c509cbb475a9f184b9650e02 (patch)
treeb829b766c67cbd28fe4a2a1ad6982d65e1914099 /ares/ares_expand_string.c
parent4186b5b41f08479b84caeca4c0e0f2dd57ae5c12 (diff)
fix compiler warning
Diffstat (limited to 'ares/ares_expand_string.c')
-rw-r--r--ares/ares_expand_string.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ares/ares_expand_string.c b/ares/ares_expand_string.c
index 6ab8a7752..3b7b34138 100644
--- a/ares/ares_expand_string.c
+++ b/ares/ares_expand_string.c
@@ -46,26 +46,30 @@ int ares_expand_string(const unsigned char *encoded,
long *enclen)
{
unsigned char *q;
- long len;
+ union {
+ ssize_t sig;
+ size_t uns;
+ } elen;
+
if (encoded == abuf+alen)
return ARES_EBADSTR;
- len = *encoded;
- if (encoded+len+1 > abuf+alen)
+ elen.uns = *encoded;
+ if (encoded+elen.sig+1 > abuf+alen)
return ARES_EBADSTR;
encoded++;
- *s = malloc(len+1);
+ *s = malloc(elen.uns+1);
if (*s == NULL)
return ARES_ENOMEM;
q = *s;
- strncpy((char *)q, (char *)encoded, len);
- q[len] = '\0';
+ strncpy((char *)q, (char *)encoded, elen.uns);
+ q[elen.uns] = '\0';
*s = q;
- *enclen = len+1;
+ *enclen = (long)(elen.sig+1);
return ARES_SUCCESS;
}