[svn] commit: r1354 - /trunk/src/lib/dns/message.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Mar 12 07:52:54 UTC 2010
Author: jinmei
Date: Fri Mar 12 07:52:53 2010
New Revision: 1354
Log:
thorw DNSMessageFORMERR instead of generic isc exception on parse errro.
Modified:
trunk/src/lib/dns/message.cc
Modified: trunk/src/lib/dns/message.cc
==============================================================================
--- trunk/src/lib/dns/message.cc (original)
+++ trunk/src/lib/dns/message.cc Fri Mar 12 07:52:53 2010
@@ -152,6 +152,13 @@
"RESERVED14",
"RESERVED15"
};
+
+static const char *sectiontext[] = {
+ "QUESTION",
+ "ANSWER",
+ "AUTHORITY",
+ "ADDITIONAL"
+};
}
string
@@ -572,21 +579,21 @@
}
int
-MessageImpl::parseQuestion(InputBuffer& buffer)
-{
+MessageImpl::parseQuestion(InputBuffer& buffer) {
unsigned int added = 0;
for (unsigned int count = 0;
count < counts_[Section::QUESTION().getCode()];
count++) {
- Name name(buffer);
+ const Name name(buffer);
if ((buffer.getLength() - buffer.getPosition()) <
2 * sizeof(uint16_t)) {
- isc_throw(MessageTooShort, "");
+ isc_throw(DNSMessageFORMERR, "Question section too short: " <<
+ (buffer.getLength() - buffer.getPosition()) << " bytes");
}
- RRType rrtype(buffer.readUint16());
- RRClass rrclass(buffer.readUint16());
+ const RRType rrtype(buffer.readUint16());
+ const RRClass rrclass(buffer.readUint16());
// XXX: need a duplicate check. We might also want to have an optimized
// algorithm that requires the question section contain exactly one
@@ -625,7 +632,9 @@
// buffer must store at least RR TYPE, RR CLASS, TTL, and RDLEN.
if ((buffer.getLength() - buffer.getPosition()) <
3 * sizeof(uint16_t) + sizeof(uint32_t)) {
- isc_throw(MessageTooShort, "");
+ isc_throw(DNSMessageFORMERR, sectiontext[section.getCode()] <<
+ " section too short: " <<
+ (buffer.getLength() - buffer.getPosition()) << " bytes");
}
RRType rrtype(buffer.readUint16());
@@ -691,13 +700,6 @@
}
namespace {
-static const char *sectiontext[] = {
- "QUESTION",
- "ANSWER",
- "AUTHORITY",
- "ADDITIONAL"
-};
-
template <typename T>
struct SectionFormatter
{
@@ -962,7 +964,8 @@
Message::beginSection(const Section& section) const
{
if (section == Section::QUESTION()) {
- isc_throw(InvalidMessageSection, "");
+ isc_throw(InvalidMessageSection,
+ "RRset iterator is requested for question");
}
return (RRsetIterator(
@@ -974,7 +977,8 @@
Message::endSection(const Section& section) const
{
if (section == Section::QUESTION()) {
- isc_throw(InvalidMessageSection, "");
+ isc_throw(InvalidMessageSection,
+ "RRset iterator is requested for question");
}
return (RRsetIterator(
More information about the bind10-changes
mailing list