]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2497] Also check and stop at END_OF_LINE
authorMukund Sivaraman <muks@isc.org>
Fri, 30 Nov 2012 04:20:23 +0000 (09:50 +0530)
committerMukund Sivaraman <muks@isc.org>
Fri, 30 Nov 2012 04:20:23 +0000 (09:50 +0530)
src/lib/dns/rdata.cc
src/lib/dns/rrparamregistry-placeholder.cc
src/lib/dns/tests/rdata_unittest.cc
src/lib/dns/tests/rrparamregistry_unittest.cc

index 06472b0b30b81e1c1de002f6fb31bf29aff49392..40b6d79dbc0c785d85b8937a468170b1a394c614 100644 (file)
@@ -204,7 +204,8 @@ Generic::Generic(MasterLexer& lexer, const Name*,
 
     while (true) {
         const MasterLexer::Token& token = lexer.getNextToken();
-        if (token.getType() == MasterLexer::Token::END_OF_FILE) {
+        if ((token.getType() == MasterLexer::Token::END_OF_FILE) ||
+            (token.getType() == MasterLexer::Token::END_OF_LINE)) {
             break;
         }
 
index e21444732be343fe7ba3b4928e26af32462e4a74..e35b2f46644d57f0ed8f66b527aa5d0c4d42f244 100644 (file)
@@ -53,7 +53,8 @@ AbstractRdataFactory::create(MasterLexer& lexer, const Name*,
 
     while (true) {
         const MasterLexer::Token& token = lexer.getNextToken();
-        if (token.getType() == MasterLexer::Token::END_OF_FILE) {
+        if ((token.getType() == MasterLexer::Token::END_OF_FILE) ||
+            (token.getType() == MasterLexer::Token::END_OF_LINE)) {
             break;
         }
 
index c80fdd0a044196af430b6a1a0f9307b781382880..984289c773d583b60fbf53dd6813c20617e7244c 100644 (file)
@@ -59,7 +59,8 @@ RdataTest::rdataFactoryFromFile(const RRType& rrtype, const RRClass& rrclass,
 
 namespace test {
 
-void dummyCallback(const string&, size_t, const string&) {
+void
+dummyCallback(const string&, size_t, const string&) {
 }
 
 RdataPtr
index 7e683834b6c90f65134d1307d470d5fd6ca29398..b749d74db78273e352d95957a978c0cb19ab5a80 100644 (file)
@@ -157,16 +157,15 @@ TEST_F(RRParamRegistryTest, addRemoveFactory) {
                      RRType(test_type_code)));
 }
 
-void dummyCallback(const string&, size_t, const string&) {
+void
+dummyCallback(const string&, size_t, const string&) {
 }
 
-TEST_F(RRParamRegistryTest, createFromLexer) {
-    // This test basically checks that the string version of
-    // AbstractRdataFactory::create() is called by the MasterLexer
-    // variant of create().
+RdataPtr
+createRdataHelper(const std::string& str) {
     boost::scoped_ptr<AbstractRdataFactory> rdf(new TestRdataFactory);
 
-    std::stringstream ss("192.168.0.1");
+    std::stringstream ss(str);
     MasterLexer lexer;
     lexer.pushSource(ss);
 
@@ -175,10 +174,22 @@ TEST_F(RRParamRegistryTest, createFromLexer) {
     MasterLoaderCallbacks callbacks(callback, callback);
     Name origin("example.org.");
 
-    const RdataPtr rdata = rdf->create(lexer, &origin,
-                                       MasterLoader::MANY_ERRORS,
-                                       callbacks);
-    EXPECT_EQ(0, in::A("192.168.0.1").compare(*rdata));
+    return (rdf->create(lexer, &origin,
+                        MasterLoader::MANY_ERRORS,
+                        callbacks));
+}
+
+TEST_F(RRParamRegistryTest, createFromLexer) {
+    // This test basically checks that the string version of
+    // AbstractRdataFactory::create() is called by the MasterLexer
+    // variant of create().
+    EXPECT_EQ(0, in::A("192.168.0.1").compare(
+              *createRdataHelper("192.168.0.1")));
+
+    // This should parse only up to the end of line. Everything that
+    // comes afterwards is not parsed.
+    EXPECT_EQ(0, in::A("192.168.0.42").compare(
+              *createRdataHelper("192.168.0.42\na b c d e f")));
 }
 
 }