]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
JSON API: Recursor: refuse invalid netmasks in allow-from 1286/head
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Mon, 17 Feb 2014 14:30:56 +0000 (15:30 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Mon, 17 Feb 2014 14:30:56 +0000 (15:30 +0100)
pdns/ws-recursor.cc
regression-tests.api/test_RecursorConfig.py

index e103d17b9291c0f02d5bbc1cb947d58ba38d05d3..4ee34e28bcbb18c68f1883cd002e7f9baacfb095 100644 (file)
@@ -76,6 +76,14 @@ static void apiServerConfigAllowFrom(HttpRequest* req, HttpResponse* resp)
       throw ApiException("'value' must be an array");
     }
 
+    for (SizeType i = 0; i < jlist.Size(); ++i) {
+      try {
+        Netmask(jlist[i].GetString());
+      } catch (NetmaskException &e) {
+        throw ApiException(e.reason);
+      }
+    }
+
     ostringstream ss;
 
     // Clear allow-from-file if set, so our changes take effect
index ede214af75b7a3490f6b6b29c29959af1aa6d745..1f98bd2cb0990d1c2a2225f6cd9ba5284e3fa83e 100644 (file)
@@ -30,3 +30,4 @@ class RecursorConfig(ApiTestCase):
             headers={'content-type': 'application/json'})
         self.assertEquals(r.status_code, 422)
         data = r.json()
+        self.assertIn('Unable to convert', data['error'])