diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-24 15:06:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-24 15:06:23 +0100 |
commit | a14a9d73b1274eb7065167914b1b47d3f5e62f6b (patch) | |
tree | fc6405485850e448baf74a2bf37d9f01594831a0 | |
parent | 651a2697f725f10c1ebdb8947925b5a9c6cf4fe2 (diff) | |
download | busybox-w32-a14a9d73b1274eb7065167914b1b47d3f5e62f6b.tar.gz busybox-w32-a14a9d73b1274eb7065167914b1b47d3f5e62f6b.tar.bz2 busybox-w32-a14a9d73b1274eb7065167914b1b47d3f5e62f6b.zip |
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.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c index c00b4ed88..93dfd9a4e 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) | |||
44 | while (crtpos < clen) { | 44 | while (crtpos < clen) { |
45 | c = cstr + crtpos; | 45 | c = cstr + crtpos; |
46 | 46 | ||
47 | if (*c & NS_CMPRSFLGS) { | 47 | if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) { |
48 | /* pointer */ | 48 | /* pointer */ |
49 | if (crtpos + 2 > clen) /* no offset to jump to? abort */ | 49 | if (crtpos + 2 > clen) /* no offset to jump to? abort */ |
50 | return NULL; | 50 | return NULL; |
51 | if (retpos == 0) /* toplevel? save return spot */ | 51 | if (retpos == 0) /* toplevel? save return spot */ |
52 | retpos = crtpos + 2; | 52 | retpos = crtpos + 2; |
53 | depth++; | 53 | depth++; |
54 | crtpos = ((c[0] & 0x3f) << 8) | (c[1] & 0xff); /* jump */ | 54 | crtpos = ((c[0] & 0x3f) << 8) | c[1]; /* jump */ |
55 | } else if (*c) { | 55 | } else if (*c) { |
56 | /* label */ | 56 | /* label */ |
57 | if (crtpos + *c + 1 > clen) /* label too long? abort */ | 57 | 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) | |||
154 | while (off < clen) { | 154 | while (off < clen) { |
155 | c = cstr + off; | 155 | c = cstr + off; |
156 | 156 | ||
157 | if ((*c & NS_CMPRSFLGS) != 0) { /* pointer, skip */ | 157 | if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) { /* pointer, skip */ |
158 | off += 2; | 158 | off += 2; |
159 | } else if (*c) { /* label, try matching dname */ | 159 | } else if (*c) { /* label, try matching dname */ |
160 | inc = *c + 1; | 160 | inc = *c + 1; |
@@ -164,8 +164,8 @@ static int find_offset(const uint8_t *cstr, int clen, const uint8_t *dname) | |||
164 | return off; | 164 | return off; |
165 | d += *c + 1; | 165 | d += *c + 1; |
166 | c += *c + 1; | 166 | c += *c + 1; |
167 | if ((*c & NS_CMPRSFLGS) != 0) /* pointer, jump */ | 167 | if ((*c & NS_CMPRSFLGS) == NS_CMPRSFLGS) /* pointer, jump */ |
168 | c = cstr + (((*c & 0x3f) << 8) | (*(c + 1) & 0xff)); | 168 | c = cstr + (((c[0] & 0x3f) << 8) | c[1]); |
169 | } | 169 | } |
170 | off += inc; | 170 | off += inc; |
171 | } else { /* null, skip */ | 171 | } else { /* null, skip */ |
@@ -196,7 +196,7 @@ uint8_t* FAST_FUNC dname_enc(const uint8_t *cstr, int clen, const char *src, int | |||
196 | for (d = dname; *d != 0; d += *d + 1) { | 196 | for (d = dname; *d != 0; d += *d + 1) { |
197 | off = find_offset(cstr, clen, d); | 197 | off = find_offset(cstr, clen, d); |
198 | if (off >= 0) { /* found a match, add pointer and terminate string */ | 198 | if (off >= 0) { /* found a match, add pointer and terminate string */ |
199 | *d++ = NS_CMPRSFLGS; | 199 | *d++ = NS_CMPRSFLGS + (off >> 8); |
200 | *d = off; | 200 | *d = off; |
201 | break; | 201 | break; |
202 | } | 202 | } |