isc_throw(InvalidRdataLength, "SRV too short");
}
- uint16_t priority = buffer.readUint16();
- uint16_t weight = buffer.readUint16();
- uint16_t port = buffer.readUint16();
+ const uint16_t priority = buffer.readUint16();
+ const uint16_t weight = buffer.readUint16();
+ const uint16_t port = buffer.readUint16();
const Name targetname(buffer);
impl_ = new SRVImpl(priority, weight, port, targetname);
}
+SRV::SRV(MasterLexer& lexer, const Name*, MasterLoader::Options,
+ MasterLoaderCallbacks&)
+{
+ uint32_t num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV priority");
+ }
+ const uint16_t priority = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV weight");
+ }
+ const uint16_t weight = static_cast<uint16_t>(num);
+
+ num = lexer.getNextToken(MasterToken::NUMBER).getNumber();
+ if (num > 65535) {
+ isc_throw(InvalidRdataText, "Invalid SRV port");
+ }
+ const uint16_t port = static_cast<uint16_t>(num);
+
+ const Name targetname =
+ Name(lexer.getNextToken(MasterToken::QSTRING).getString());
+
+ impl_ = new SRVImpl(priority, weight, port, targetname);
+}
+
/// \brief The copy constructor.
///
/// It internally allocates a resource, and if it fails a corresponding
"1 5 1500 a.example.com.")));
// Exceptions cause NULL to be returned.
+
+ // Bad priority
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "65536 5 1500 "
+ "a.example.com."));
+ // Bad weight
+ EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
+ "1 65536 1500 "
+ "a.example.com."));
+ // Bad port
EXPECT_FALSE(test::createRdataUsingLexer(RRType::SRV(), RRClass::IN(),
"1 5 281474976710656 "
"a.example.com."));