BIND 10 #2396: Add IOAddress::toBytes()

BIND 10 Development do-not-reply at isc.org
Wed Dec 5 18:20:13 UTC 2012


#2396: Add IOAddress::toBytes()
-------------------------------------+-------------------------------------
            Reporter:  stephen       |                        Owner:
                Type:  enhancement   |  stephen
            Priority:  medium        |                       Status:
           Component:  dhcp          |  reviewing
            Keywords:                |                    Milestone:
           Sensitive:  0             |  Sprint-DHCP-20121213
         Sub-Project:  DHCP          |                   Resolution:
Estimated Difficulty:  0             |                 CVSS Scoring:
         Total Hours:  0             |              Defect Severity:  N/A
                                     |  Feature Depending on Ticket:
                                     |          Add Hours to Ticket:  0
                                     |                    Internal?:  0
-------------------------------------+-------------------------------------
Changes (by marcin):

 * owner:  marcin => stephen


Comment:

 Reviewed commit 8bc5490b0e4718fcf5759a0b24c02a83c4518e17

 '''io_address.h'''
 The new IOAddress::isVx() functions "kind of" duplicate the functionality
 of getFamily(). Are these new functions really necessary?

 '''io_address_unittest.cc'''
 In the following code:
 {{{
 EXPECT_EQ(sizeof(V4), v4bytes.size());
 EXPECT_TRUE(std::equal(v4bytes.begin(), v4bytes.end(), &V4[0]));
 }}}
 which checks that the size of a reference data and a vector are equal but
 then it goes forward to actually compare the buffers regardless of the
 size check result. There are two reasons why you should use ASSERT_EQ when
 doing a size check:
 1. If the returned value (v6bytes stores  { 0xc0, 0x00, 0x02 }) it will
 fail the size check value but it will pass the data check (because only 3
 bytes are compared) which is a little misleading.

 2. If the returned value (v6bytes stores an extra byte { 0xc0, 0x00, 0x02,
 0x01, 0xAA }) then you compare the 5 bytes of the vector with 5 bytes of
 V4STRING while V4STRING actually holds only 4 bytes so you end up
 comparing the 5th byte with a garbage value.

-- 
Ticket URL: <http://bind10.isc.org/ticket/2396#comment:5>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list