Opened 9 years ago

Closed 4 years ago

#318 closed defect (invalid)

MSVC++ detected errors and warnings in libdns++

Reported by: stephen Owned by: stephen
Priority: low Milestone: Remaining BIND10 tickets
Component: libdns++ Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DNS Feature Depending on Ticket:
Estimated Difficulty: 0.0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

I've run the libdns++ code in revision 2798 of the trunk through the Microsoft Visual C++ compiler and it has thrown up a number of warnings and errors. Those that are relevant to the Unix version of BIND are listed below; the more Windows-specific erors (e.g. use of a function for which there is no equivalent in Windows) will be the subject of another ticket.

src/lib/dns/rdata/generic/dnskey_48.cc
DNSKEY::DNSKEY(InputBuffer& buffer, size_t rdata_len)

uint16_t protocol = buffer.readUint8();
uint16_t algorithm = buffer.readUint8();

The declarations should be uint8_t. These variables are passed to the constructor of DNSKEYImpl (which expects them as uint8_t) and the compiler warns about the conversion of a uint16_t to a uint8_t.

DNSKEY::getTag()

for (int i = 0; i < size; i ++)

Compiler warns about a signed/unsigned comparison mismatch (size is declared as size_t).

src/lib/dns/rdata/generic/ds_43.cc
DS::DS(InputBuffer& buffer, size_t rdata_len)

uint16_t protocol = buffer.readUint8()
uint16_t algorithm = buffer.readUint8()

The declarations should be uint8_t. These variables are passed to the constructor of DSImpl (which expects them as uint8_t) and the compiler warns about the conversion of a uint16_t to a uint8_t.

src/lib/dns/rdata/generic/nsec3param_51.cc
NSEC3PARAM::NSEC3PARAM(const string& nsec3param_str)

uint16_t hashalg, flags, iterations

hashalg and flags should be declared uint8_t. These variables are passed to the constructor of NSEC3PARAMImpl (which expects them as uint8_t) and the compiler warns about the conversion of a uint16_t to a uint8_t.

src/lib/dns/rdata/generic/nsec3_50.cc
NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len)

for (int i = 0; i < typebits.size(); i += len)
if (i + 2 > typebits.size())

Compiler warns about a signed/unsigned comparison mismatch.

NSEC3::toText()

for (int i = 0; i < impl_->typebits_.size(); i += len)
assert(i + 2 <= impl_->typebits_.size())

Compiler warns about a signed/unsigned comparison mismatch.

NSEC::NSEC(InputBuffer& buffer, size_t rdata_len)

for (int i = 0; i < rdata_len; i += len)
if (i + 2 > rdata_len)

and

if (i + len > rdata_len)

Compiler warns about a signed/unsigned comparison mismatch.

NSEC::toText()

for (int i = 0; i < impl_->typebits_.size(); i += len)
assert(i + 2 <= impl_->typebits_.size());

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/rdata/generic/rrsig_46.cc
RRSIG::RRSIG(const string& rrsig_str)

uint32_t timeexpire = timeFromText(expire_txt);
uint32_t timeinception = timeFromText(inception_txt);

timeFromText returns a time_t value. Under Windows, time_t is 64 bits, so the compiler is warning about a possible loss of data. (Suggestion: as the value of the inception and expiration times in an RRSIG are defined to be unsigned 32-bit values, altering the return type of the timeFromText() function would seem to be a better fix than changing the data types of timeexpire and timeexception.)

src/lib/dns/rdata/generic/txt_16.cc
TXT::TXT(InputBuffer& buffer, size_t rdata_len)

if (rdata_len < len + 1)

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/rdata.cc
Generic::Generic(const string& rdata_string)

while (!iss.eof() && data.size() < rdlen)

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/name.cc
Name::toText(bool omit_final_dot)

assert(np_end - np >= count);

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/message.h
message.h forward declares MessageImpl as a struct but message.c defines it as a class. The compiler warns about the mismatch.

src/lib/dns/message.cc
MessageImpl::parseQuestion(InputBuffer& buffer)

for (unsigned int count = 0;
count < counts_[Section::QUESTION().getCode()];
++count)

Compiler warns about a signed/unsigned comparison mismatch.

MessageImpl::parseSection(const Section& section, InputBuffer& buffer)

for (unsigned int count = 0; count < counts_[section.getCode()]; ++count)

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/dnssectime.cc
timeFromText(const string& time_txt)

for (int i = 0; i < time_txt.length(); ++i)

Compiler warns about a signed/unsigned comparison mismatch.

src/lib/dns/messagerenderer.c
MessageRenderer::writeName(const Name& name, const bool compress)

std::set<NameCompressNode>::const_iterator notfound = impl_->nodeset_.end();

This gives an error because notfound is declared as:

std::set<NameCompressNode>::const_iterator

... but nodeset_.end() has type:

std::set<NameCompressNode, NameCompare>::const_iterator

Subtickets

Change History (4)

comment:1 Changed 8 years ago by shane

  • Defect Severity set to N/A
  • Owner set to stephen
  • Status changed from new to assigned
  • Sub-Project set to DNS

I believe these were handled in ticket #1470. Stephen, does this seem likely to you?

comment:2 Changed 5 years ago by tomek

  • Milestone set to Remaining BIND10 tickets

comment:3 Changed 5 years ago by tomek

  • Component changed from Unclassified to libdns++
  • Version set to git

comment:4 Changed 4 years ago by tomek

  • Resolution set to invalid
  • Status changed from assigned to closed

Francis is working on MSVC++ support. Info in this ticket is 5 years old. Closing.

Note: See TracTickets for help on using tickets.