From: Christian Hofstaedtler Date: Mon, 17 Feb 2014 14:30:56 +0000 (+0100) Subject: JSON API: Recursor: refuse invalid netmasks in allow-from X-Git-Tag: rec-3.6.0-rc1~176^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=faa0f891c3bed6fcff45112c5e81c882147e41c1;p=thirdparty%2Fpdns.git JSON API: Recursor: refuse invalid netmasks in allow-from --- diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index e103d17b92..4ee34e28bc 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -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 diff --git a/regression-tests.api/test_RecursorConfig.py b/regression-tests.api/test_RecursorConfig.py index ede214af75..1f98bd2cb0 100644 --- a/regression-tests.api/test_RecursorConfig.py +++ b/regression-tests.api/test_RecursorConfig.py @@ -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'])