]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
519. [bug] dns_name_split() would improperly split some bitstring
authorDavid Lawrence <source@isc.org>
Sat, 14 Oct 2000 04:31:31 +0000 (04:31 +0000)
committerDavid Lawrence <source@isc.org>
Sat, 14 Oct 2000 04:31:31 +0000 (04:31 +0000)
labels, zeroing a few of the least signficant bits in
the prefix part.  When such an improperly created
prefix was returned to the RBT database, the bogus
label was dutifully stored, corrupting the tree.
[RT #369]

Also made dns_name_split() REQUIRE that suffixlabels always be greater than 0,
even when splitting a bitstring label (it already required this when not
splitting a bitstring label).  This is consistent with the way dns_name_split()
was called to split a name that consisted of a single label, a bitstring;
the appropriate suffixlabels value is 1 in such cases.

Also a fixed minor style error, and a confusing comment.

CHANGES
lib/dns/name.c

diff --git a/CHANGES b/CHANGES
index 05a376e5f9f21e3a7224b0426fb2a3c14db5df0a..e718c2a3d174abd6c0168946eaa42dc6ff3b65ac 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+ 519.  [bug]           dns_name_split() would improperly split some bitstring
+                       labels, zeroing a few of the least signficant bits in
+                       the prefix part.  When such an improperly created
+                       prefix was returned to the RBT database, the bogus
+                       label was dutifully stored, corrupting the tree.
+                       [RT #369]
+
  518.  [bug]           The resolver did not realize that a DNAME which was
                        "the answer" to the client's query was "the answer",
                        and such queries would fail. [RT #399]
index 1e449b9ae04f4ceafb12b8f300fbc5ec3ccd511c..b3aacafb2496fbc24e1ad95b8b9684f7f55a61df 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: name.c,v 1.104 2000/10/11 17:44:12 mws Exp $ */
+/* $Id: name.c,v 1.105 2000/10/14 04:31:31 tale Exp $ */
 
 #include <config.h>
 
@@ -2741,6 +2741,15 @@ dns_name_split(dns_name_t *name,
                                        memcpy(dst, src, len);
 
                        } else {
+                               /*
+                                * p is adjusted to point to the last byte of
+                                * the starting bitstring label to make it
+                                * cheap to determine when bits from the next
+                                * byte should be shifted into the low order
+                                * bits of the current byte.
+                                */
+                               p = src + (mod + *p - 1) / 8;
+
                                while (len--) {
                                        *dst = *src++ << mod;
                                        /*
@@ -2748,7 +2757,7 @@ dns_name_split(dns_name_t *name,
                                         * against arithmetic sign extension
                                         * by the right shift.
                                         */
-                                       if (len > 0)
+                                       if (src <= p)
                                                *dst++ |=
                                                        (*src >> (8 - mod)) &
                                                        ~(0xFF << mod);