diff options
author | Yu Jiung <jiung.yu@samsung.com> | 2016-11-10 16:24:08 +0900 |
---|---|---|
committer | Yu Jiung <jiung.yu@samsung.com> | 2016-11-10 16:25:02 +0900 |
commit | 8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8 (patch) | |
tree | 81f0750d91aa467df3ee81cf30d22a65db2e6685 /ares_expand_name.c | |
parent | ccccebb78520ec3a26a18370936516b12ae5d53a (diff) | |
parent | 45e88a8337839e5fd88519bc55467053d521c9f6 (diff) | |
download | c-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.tar.gz c-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.tar.bz2 c-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.zip |
Merge branch 'tizen' into tizen_basetizen_4.0.m2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_base/20170705.023439submit/tizen_base/20170703.013654submit/tizen_4.0_base/20170828.000001submit/tizen_4.0_base/20170828.000000submit/tizen_4.0_base/20170811.071500accepted/tizen/base/20170707.183634accepted/tizen/4.0/base/20170828.221324accepted/tizen/4.0/base/20170811.093019
Conflicts:
packaging/c-ares.spec
Change-Id: I1ec10e394aed3ef19ee21fefbe3aba7d7a615c74
Diffstat (limited to 'ares_expand_name.c')
-rw-r--r-- | ares_expand_name.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/ares_expand_name.c b/ares_expand_name.c index 2aa12bc..738be8d 100644 --- a/ares_expand_name.c +++ b/ares_expand_name.c @@ -74,7 +74,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, if (nlen.sig < 0) return ARES_EBADNAME; - *s = malloc(nlen.uns + 1); + *s = ares_malloc(nlen.uns + 1); if (!*s) return ARES_ENOMEM; q = *s; @@ -129,7 +129,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, if (q > *s) *(q - 1) = 0; else - *q = 0; /* zero terminate */ + *q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */ return ARES_SUCCESS; } @@ -140,7 +140,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, static int name_length(const unsigned char *encoded, const unsigned char *abuf, int alen) { - int n = 0, offset, indir = 0; + int n = 0, offset, indir = 0, top; /* Allow the caller to pass us abuf + alen and have us check for it. */ if (encoded >= abuf + alen) @@ -148,7 +148,8 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, while (*encoded) { - if ((*encoded & INDIR_MASK) == INDIR_MASK) + top = (*encoded & INDIR_MASK); + if (top == INDIR_MASK) { /* Check the offset and go there. */ if (encoded + 1 >= abuf + alen) @@ -164,7 +165,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, if (++indir > alen) return -1; } - else + else if (top == 0x00) { offset = *encoded; if (encoded + offset + 1 >= abuf + alen) @@ -177,6 +178,13 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, } n++; } + else + { + /* RFC 1035 4.1.4 says other options (01, 10) for top 2 + * bits are reserved. + */ + return -1; + } } /* If there were any labels at all, then the number of dots is one |