]> granicus.if.org Git - curl/commitdiff
fix compiler warning
authorYang Tse <yangsita@gmail.com>
Tue, 23 Feb 2010 18:46:27 +0000 (18:46 +0000)
committerYang Tse <yangsita@gmail.com>
Tue, 23 Feb 2010 18:46:27 +0000 (18:46 +0000)
ares/ares_expand_name.c
ares/ares_expand_string.c

index 5a48b4d593a346db508b754b1f9e054ae9b40a07..fd3220d690d136b68cd7d92be410178c96143a9a 100644 (file)
@@ -69,17 +69,21 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
   int len, indir = 0;
   char *q;
   const unsigned char *p;
+  union {
+    ssize_t sig;
+     size_t uns;
+  } nlen;
 
-  len = name_length(encoded, abuf, alen);
-  if (len < 0)
+  nlen.sig = name_length(encoded, abuf, alen);
+  if (nlen.sig < 0)
     return ARES_EBADNAME;
 
-  *s = malloc(((size_t)len) + 1);
+  *s = malloc(nlen.uns + 1);
   if (!*s)
     return ARES_ENOMEM;
   q = *s;
 
-  if (len == 0) {
+  if (nlen.uns == 0) {
     /* RFC2181 says this should be ".": the root of the DNS tree.
      * Since this function strips trailing dots though, it becomes ""
      */
index 6ab8a775252991e98d5ccfbd4895a210d56d4312..3b7b34138ebc0d9ebe4b7128529cb9d8247b82ff 100644 (file)
@@ -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;
 }