summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2010-03-24 15:06:23 +0100
committerDenys Vlasenko2010-03-24 15:06:23 +0100
commita14a9d73b1274eb7065167914b1b47d3f5e62f6b (patch)
treefc6405485850e448baf74a2bf37d9f01594831a0
parent651a2697f725f10c1ebdb8947925b5a9c6cf4fe2 (diff)
downloadbusybox-a14a9d73b1274eb7065167914b1b47d3f5e62f6b.zip
busybox-a14a9d73b1274eb7065167914b1b47d3f5e62f6b.tar.gz
udhcp: fix DNS domanin codec bug: bad compression flag checks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/domain_codec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c
index c00b4ed..93dfd9a 100644
--- a/networking/udhcp/domain_codec.c
+++ b/networking/udhcp/domain_codec.c
@@ -44,14 +44,14 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre)
while (crtpos < clen) {
c = cstr + crtpos;
- if (*c & NS_CMPRSFLGS) {
+ if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
/* pointer */
if (crtpos + 2 > clen) /* no offset to jump to? abort */
return NULL;
if (retpos == 0) /* toplevel? save return spot */
retpos = crtpos + 2;
depth++;
- crtpos = ((c[0] & 0x3f) << 8) | (c[1] & 0xff); /* jump */
+ crtpos = ((c[0] & 0x3f) << 8) | c[1]; /* jump */
} else if (*c) {
/* label */
if (crtpos + *c + 1 > clen) /* label too long? abort */
@@ -154,7 +154,7 @@ static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname)
while (off < clen) {
c = cstr + off;
- if ((*c & NS_CMPRSFLGS) != 0) { /* pointer, skip */
+ if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) { /* pointer, skip */
off += 2;
} else if (*c) { /* label, try matching dname */
inc = *c + 1;
@@ -164,8 +164,8 @@ static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname)
return off;
d += *c + 1;
c += *c + 1;
- if ((*c & NS_CMPRSFLGS) != 0) /* pointer, jump */
- c = cstr + (((*c & 0x3f) << 8) | (*(c + 1) & 0xff));
+ if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) /* pointer, jump */
+ c = cstr + (((c[0] & 0x3f) << 8) | c[1]);
}
off += inc;
} else { /* null, skip */
@@ -196,7 +196,7 @@ uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int
for (d = dname; *d != 0; d += *d + 1) {
off = find_offset(cstr, clen, d);
if (off >= 0) { /* found a match, add pointer and terminate string */
- *d++ = NS_CMPRSFLGS;
+ *d++ = NS_CMPRSFLGS + (off >> 8);
*d = off;
break;
}