Commit c215be2c authored by Evan Hunt's avatar Evan Hunt
Browse files

- use DNSMessageFORMERR exception type instead of InvalidRdata

- use an explicit long-long constant for the dnssectime overflow test


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1353 e5f2f494-b856-4b98-b285-d166d9295462
parent 207d804e
......@@ -54,17 +54,6 @@ public:
isc::Exception(file, line, what) {}
};
///
/// \brief A standard DNS module exception that is thrown if wire format
/// RDTA is invalid
///
class InvalidRdata : public Exception {
public:
InvalidRdata(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
///
/// \brief A standard DNS module exception that is thrown if RDATA parser
/// parser encounters a character-string (as defined in RFC1035) exceeding
......
......@@ -24,6 +24,7 @@
#include "base32.h"
#include "buffer.h"
#include "exceptions.h"
#include "hex.h"
#include "messagerenderer.h"
#include "name.h"
......@@ -170,11 +171,13 @@ NSEC3::NSEC3(InputBuffer& buffer, size_t rdata_len)
int len = 0;
for (int i = 0; i < typebits.size(); i += len) {
if (i + 2 > typebits.size()) {
isc_throw(InvalidRdata, "Bad NSEC3 typebits");
isc_throw(DNSMessageFORMERR, "Invalid rdata: "
"bad NSEC3 type bitmap");
}
len = typebits[i + 1];
if (len > 31) {
isc_throw(InvalidRdata, "Bad NSEC3 typebits");
isc_throw(DNSMessageFORMERR, "Invalid rdata: "
"bad NSEC3 type bitmap");
}
i += 2;
}
......
......@@ -23,6 +23,7 @@
#include "base64.h"
#include "buffer.h"
#include "exceptions.h"
#include "messagerenderer.h"
#include "name.h"
#include "rrtype.h"
......@@ -110,11 +111,13 @@ NSEC::NSEC(InputBuffer& buffer, size_t rdata_len)
int len = 0;
for (int i = 0; i < typebits.size(); i += len) {
if (i + 2 > typebits.size()) {
isc_throw(InvalidRdata, "Bad NSEC typebits");
isc_throw(DNSMessageFORMERR, "Invalid rdata: "
"bad NSEC type bitmap");
}
len = typebits[i + 1];
if (len > 31) {
isc_throw(InvalidRdata, "Bad NSEC typebits");
isc_throw(DNSMessageFORMERR, "Invalid rdata: "
"bad NSEC type bitmap");
}
i += 2;
}
......
......@@ -63,6 +63,6 @@ TEST(DNSSECTimeTest, toText)
EXPECT_EQ("20100311233000", timeToText(1268350200));
// Jan 1, Year 10,000. What should we do?
EXPECT_THROW(timeToText(253402300800), InvalidTime);
EXPECT_THROW(timeToText(253402300800LL), InvalidTime);
}
}
......@@ -18,6 +18,7 @@
#include <dns/base32.h>
#include <dns/buffer.h>
#include <dns/exceptions.h>
#include <dns/hex.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
......@@ -88,7 +89,7 @@ TEST_F(Rdata_NSEC3_Test, createFromWire)
// Invalid type bits
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC3(), RRClass::IN(),
"testdata/rdata_nsec3_fromWire3"),
InvalidRdata);
DNSMessageFORMERR);
}
TEST_F(Rdata_NSEC3_Test, toWireRenderer)
......
......@@ -17,6 +17,7 @@
#include <string>
#include <dns/buffer.h>
#include <dns/exceptions.h>
#include <dns/messagerenderer.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
......@@ -68,7 +69,7 @@ TEST_F(Rdata_NSEC_Test, createFromWire_NSEC)
EXPECT_THROW(rdataFactoryFromFile(RRType::NSEC(), RRClass::IN(),
"testdata/rdata_nsec_fromWire3"),
InvalidRdata);
DNSMessageFORMERR);
}
TEST_F(Rdata_NSEC_Test, toWireRenderer_NSEC)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment