Commit f3ca4f39 authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2521] RFC4034 only allows unsigned int in the RRSIG Original TTL field

parent b4093345
......@@ -26,7 +26,6 @@
#include <dns/messagerenderer.h>
#include <dns/name.h>
#include <dns/rrtype.h>
#include <dns/rrttl.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdata/generic/detail/lexer_util.h>
......@@ -89,7 +88,7 @@ RRSIG::createFromLexer(MasterLexer& lexer, const Name* origin) {
isc_throw(InvalidRdataText, "RRSIG labels out of range");
}
const uint32_t originalttl =
RRTTL(lexer.getNextToken(MasterToken::STRING).getString()).getValue();
lexer.getNextToken(MasterToken::NUMBER).getNumber();
const uint32_t timeexpire =
timeFromText32(lexer.getNextToken(MasterToken::STRING).getString());
const uint32_t timeinception =
......@@ -135,7 +134,7 @@ RRSIG::createFromLexer(MasterLexer& lexer, const Name* origin) {
///
/// See the construction that takes \c MasterLexer for other fields.
///
/// \throw Others Exception from the Name and RRTTL constructors.
/// \throw Others Exception from the Name constructor.
/// \throw InvalidRdataText Other general syntax errors.
RRSIG::RRSIG(const std::string& rrsig_str) :
impl_(NULL)
......@@ -164,13 +163,12 @@ RRSIG::RRSIG(const std::string& rrsig_str) :
/// origin is non NULL, in which case \c origin is used to make it absolute.
/// This must not be represented as a quoted string.
///
/// The Original TTL field can be either a valid decimal representation of an
/// unsigned 32-bit integer or other valid textual representation of \c RRTTL
/// such as "1H" (which means 3600). Note that this differs from BIND 9,
/// which only allows the Original TTL field to be expressed in seconds.
/// The Original TTL field is a valid decimal representation of an
/// unsigned 32-bit integer. Note that RFC4034 does not allow alternate
/// textual representations of \c RRTTL such as "1H" for 3600 seconds.
///
/// \throw MasterLexer::LexerError General parsing error such as missing field.
/// \throw Other Exceptions from the Name and RRTTL constructors if
/// \throw Other Exceptions from the Name constructor if
/// construction of textual fields as these objects fail.
///
/// \param lexer A \c MasterLexer object parsing a master file for the
......
......@@ -18,7 +18,6 @@
#include <dns/name.h>
#include <dns/rrtype.h>
#include <dns/rrttl.h>
#include <dns/rdata.h>
// BEGIN_HEADER_GUARD
......
......@@ -61,11 +61,6 @@ protected:
rdata_str, rdata_rrsig, true, true);
}
void checkFromText_InvalidTTL(const string& rdata_str) {
checkFromText<generic::RRSIG, InvalidRRTTL, InvalidRRTTL>(
rdata_str, rdata_rrsig, true, true);
}
void checkFromText_InvalidTime(const string& rdata_str) {
checkFromText<generic::RRSIG, InvalidTime, InvalidTime>(
rdata_str, rdata_rrsig, true, true);
......@@ -118,14 +113,6 @@ TEST_F(Rdata_RRSIG_Test, fromText) {
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU\n"
"f49t+sXKPzbipN9g+s1ZPiIyofc= )");
// Alternate form of TTL is okay
checkFromText_None(
"A 5 4 12H 20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz "
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/ "
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU "
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
// Trailing garbage. This should cause only the string constructor
// to fail, but the lexer constructor must be able to continue
// parsing from it.
......@@ -159,14 +146,14 @@ TEST_F(Rdata_RRSIG_Test, badText) {
// bad algorithm
checkFromText_InvalidText(
"A 555 4 43200 "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_LexerError(
"A FIVE 4 43200 "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
......@@ -174,44 +161,51 @@ TEST_F(Rdata_RRSIG_Test, badText) {
// bad labels
checkFromText_InvalidText(
"A 5 4444 43200 "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_LexerError(
"A 5 FOUR 43200 "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
// bad original ttl
checkFromText_InvalidTTL(
checkFromText_LexerError(
"A 5 4 999999999999 "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_InvalidTTL(
checkFromText_LexerError(
"A 5 4 TTL "
"20100223214617 20100222214617 8496 isc.org."
"20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
// Alternate form of TTL is not okay
checkFromText_LexerError(
"A 5 4 12H 20100223214617 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz "
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/ "
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU "
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
// bad signature expiration
checkFromText_InvalidTime(
"A 5 4 43200 "
"201002232 20100222214617 8496 isc.org."
"201002232 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_InvalidTime(
"A 5 4 43200 "
"EXPIRATION 20100222214617 8496 isc.org."
"EXPIRATION 20100222214617 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
......@@ -219,14 +213,14 @@ TEST_F(Rdata_RRSIG_Test, badText) {
// bad signature inception
checkFromText_InvalidTime(
"A 5 4 43200 "
"20100223214617 20100227 8496 isc.org."
"20100223214617 20100227 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_InvalidTime(
"A 5 4 43200 "
"20100223214617 INCEPTION 8496 isc.org."
"20100223214617 INCEPTION 8496 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
......@@ -234,14 +228,14 @@ TEST_F(Rdata_RRSIG_Test, badText) {
// bad key tag
checkFromText_InvalidText(
"A 5 4 43200 "
"20100223214617 20100222214617 999999 isc.org."
"20100223214617 20100222214617 999999 isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
"f49t+sXKPzbipN9g+s1ZPiIyofc=");
checkFromText_LexerError(
"A 5 4 43200 "
"20100223214617 20100222214617 TAG isc.org."
"20100223214617 20100222214617 TAG isc.org. "
"evxhlGx13mpKLVkKsjpGzycS5twtIoxOmlN14w9t5AgzGBmz"
"diGdLIrFabqr72af2rUq+UDBKMWXujwZTZUTws32sVldDPk/"
"NbuacJM25fQXfv5mO3Af7TOoow3AjMaVG9icjCW0V55WcWQU"
......
Supports Markdown
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