diff options
author | Yu Jiung <jiung.yu@samsung.com> | 2016-11-09 11:15:33 +0900 |
---|---|---|
committer | Yu Jiung <jiung.yu@samsung.com> | 2016-11-09 11:15:43 +0900 |
commit | b6627e2c19506bd30328969ea8aab73fa0945f36 (patch) | |
tree | 24b768763efadd60f318873601e58dd98fe9714c /ares_expand_name.c | |
parent | b8e6c26b7b9608dffc84645f17fe4cf534af18dd (diff) | |
download | c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.gz c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.bz2 c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.zip |
Imported Upstream version 1.10.0
Change-Id: Ic7f3b0ad7dca62abe4cfa642a5eb5e190eb7a8c9
Diffstat (limited to 'ares_expand_name.c')
-rw-r--r-- | ares_expand_name.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ares_expand_name.c b/ares_expand_name.c index e3eccd2..2aa12bc 100644 --- a/ares_expand_name.c +++ b/ares_expand_name.c @@ -1,5 +1,5 @@ -/* Copyright 1998 by the Massachusetts Institute of Technology. +/* Copyright 1998, 2011 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -16,9 +16,6 @@ #include "ares_setup.h" -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> #endif @@ -31,8 +28,8 @@ # include <arpa/nameser_compat.h> #endif -#include <stdlib.h> #include "ares.h" +#include "ares_nowarn.h" #include "ares_private.h" /* for the memdebug */ static int name_length(const unsigned char *encoded, const unsigned char *abuf, @@ -91,9 +88,9 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, /* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but valid) */ if ((*encoded & INDIR_MASK) == INDIR_MASK) - *enclen = 2; + *enclen = 2L; else - *enclen = 1; /* the caller should move one byte to get past this */ + *enclen = 1L; /* the caller should move one byte to get past this */ return ARES_SUCCESS; } @@ -106,7 +103,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, { if (!indir) { - *enclen = p + 2 - encoded; + *enclen = aresx_uztosl(p + 2U - encoded); indir = 1; } p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1)); @@ -126,7 +123,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, } } if (!indir) - *enclen = p + 1 - encoded; + *enclen = aresx_uztosl(p + 1U - encoded); /* Nuke the trailing period if we wrote one. */ if (q > *s) @@ -146,7 +143,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, int n = 0, offset, indir = 0; /* Allow the caller to pass us abuf + alen and have us check for it. */ - if (encoded == abuf + alen) + if (encoded >= abuf + alen) return -1; while (*encoded) |