BIND 10 trac363, updated. ac453e66538072059954b8ca3e3d53bfc7c8cef3 [trac363] minor fix according to review comments
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Mar 16 07:24:05 UTC 2011
The branch, trac363 has been updated
via ac453e66538072059954b8ca3e3d53bfc7c8cef3 (commit)
from 3cc446d3ed8a1b6c899ee19faeda2c41a4b5bdb2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ac453e66538072059954b8ca3e3d53bfc7c8cef3
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date: Wed Mar 16 15:20:50 2011 +0800
[trac363] minor fix according to review comments
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/python/edns_python.cc | 1 -
src/lib/dns/python/message_python.cc | 21 +++++++--------------
src/lib/dns/python/messagerenderer_python.cc | 5 ++---
src/lib/dns/python/name_python.cc | 23 ++++++++++-------------
src/lib/dns/python/rcode_python.cc | 4 ++--
src/lib/dns/python/tests/message_python_test.py | 2 +-
src/lib/dns/python/tests/name_python_test.py | 3 +--
7 files changed, 23 insertions(+), 36 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/python/edns_python.cc b/src/lib/dns/python/edns_python.cc
index 97fb13d..0622618 100644
--- a/src/lib/dns/python/edns_python.cc
+++ b/src/lib/dns/python/edns_python.cc
@@ -305,7 +305,6 @@ EDNS_setUDPSize(s_EDNS* self, PyObject* args) {
return (NULL);
}
if (size < 0 || size > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"UDP size is not an unsigned 16-bit integer");
return (NULL);
diff --git a/src/lib/dns/python/message_python.cc b/src/lib/dns/python/message_python.cc
index 0bfc9e4..34258e9 100644
--- a/src/lib/dns/python/message_python.cc
+++ b/src/lib/dns/python/message_python.cc
@@ -226,9 +226,9 @@ static PyTypeObject message_type = {
static int
Message_init(s_Message* self, PyObject* args) {
- long i;
-
- if (PyArg_ParseTuple(args, "l", &i)) {
+ int i;
+
+ if (PyArg_ParseTuple(args, "i", &i)) {
PyErr_Clear();
if (i == Message::PARSE) {
self->message = new Message(Message::PARSE);
@@ -284,7 +284,6 @@ Message_setHeaderFlag(s_Message* self, PyObject* args) {
return (NULL);
}
if (messageflag < 0 || messageflag > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError, "Message header flag out of range");
return (NULL);
}
@@ -311,15 +310,14 @@ Message_getQid(s_Message* self) {
static PyObject*
Message_setQid(s_Message* self, PyObject* args) {
- int id;
- if (!PyArg_ParseTuple(args, "i", &id)) {
+ long id;
+ if (!PyArg_ParseTuple(args, "l", &id)) {
PyErr_Clear();
PyErr_SetString(PyExc_TypeError,
"no valid type in set_qid argument");
return (NULL);
}
if (id < 0 || id > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"Message id out of range");
return (NULL);
@@ -582,11 +580,6 @@ Message_addRRset(s_Message* self, PyObject* args) {
&PyBool_Type, &sign)) {
return (NULL);
}
- if (section < 0 || section > 3) {
- PyErr_Clear();
- PyErr_SetString(PyExc_OverflowError, "Message section number out of range");
- return (NULL);
- }
try {
self->message->addRRset(static_cast<Message::Section>(section),
@@ -607,8 +600,8 @@ Message_addRRset(s_Message* self, PyObject* args) {
static PyObject*
Message_clear(s_Message* self, PyObject* args) {
- long i;
- if (PyArg_ParseTuple(args, "l", &i)) {
+ int i;
+ if (PyArg_ParseTuple(args, "i", &i)) {
PyErr_Clear();
if (i == Message::PARSE) {
self->message->clear(Message::PARSE);
diff --git a/src/lib/dns/python/messagerenderer_python.cc b/src/lib/dns/python/messagerenderer_python.cc
index 8e0421d..49fa3e0 100644
--- a/src/lib/dns/python/messagerenderer_python.cc
+++ b/src/lib/dns/python/messagerenderer_python.cc
@@ -186,7 +186,6 @@ MessageRenderer_setLengthLimit(s_MessageRenderer* self,
return (NULL);
}
if (lengthlimit < 0 || lengthlimit > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"MessageRenderer length limit out of range");
return (NULL);
@@ -199,8 +198,8 @@ static PyObject*
MessageRenderer_setCompressMode(s_MessageRenderer* self,
PyObject* args)
{
- long mode;
- if (!PyArg_ParseTuple(args, "l", &mode)) {
+ int mode;
+ if (!PyArg_ParseTuple(args, "i", &mode)) {
return (NULL);
}
diff --git a/src/lib/dns/python/name_python.cc b/src/lib/dns/python/name_python.cc
index e079313..7be83b7 100644
--- a/src/lib/dns/python/name_python.cc
+++ b/src/lib/dns/python/name_python.cc
@@ -329,10 +329,9 @@ Name_init(s_Name* self, PyObject* args) {
&PyBool_Type, &downcase) &&
PyObject_AsCharBuffer(bytes_obj, &bytes, &len) != -1) {
try {
- if (position < 0 || position > 0xffff) {
- PyErr_Clear();
- PyErr_SetString(PyExc_OverflowError,
- "Name index out of range");
+ if (position < 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "Name index shouldn't be negative");
return (-1);
}
InputBuffer buffer(bytes, len);
@@ -369,12 +368,11 @@ Name_destroy(s_Name* self) {
static PyObject*
Name_at(s_Name* self, PyObject* args) {
- long pos;
- if (!PyArg_ParseTuple(args, "l", &pos)) {
+ int pos;
+ if (!PyArg_ParseTuple(args, "i", &pos)) {
return (NULL);
}
if (pos < 0 || pos > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"name index out of range");
return (NULL);
@@ -470,14 +468,13 @@ Name_equals(s_Name* self, PyObject* args) {
Py_RETURN_FALSE;
}
-static PyObject*
+static PyObject*
Name_split(s_Name* self, PyObject* args) {
- long first, n;
+ int first, n;
s_Name* ret = NULL;
- if (PyArg_ParseTuple(args, "ll", &first, &n)) {
+ if (PyArg_ParseTuple(args, "ii", &first, &n)) {
if (first < 0 || first > 0xffff || n < 0 || n > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"name index out of range");
return (NULL);
@@ -496,9 +493,9 @@ Name_split(s_Name* self, PyObject* args) {
return (NULL);
}
}
- } else if (PyArg_ParseTuple(args, "l", &n)) {
+ } else if (PyArg_ParseTuple(args, "i", &n)) {
+ PyErr_Clear();
if (n < 0 || n > 0xffff) {
- PyErr_Clear();
PyErr_SetString(PyExc_OverflowError,
"name index out of range");
return (NULL);
diff --git a/src/lib/dns/python/rcode_python.cc b/src/lib/dns/python/rcode_python.cc
index 8e5674b..311f471 100644
--- a/src/lib/dns/python/rcode_python.cc
+++ b/src/lib/dns/python/rcode_python.cc
@@ -172,7 +172,7 @@ PyTypeObject rcode_type = {
int
Rcode_init(s_Rcode* const self, PyObject* args) {
long code = 0;
- long ext_code = 0;
+ int ext_code = 0;
if (PyArg_ParseTuple(args, "l", &code)) {
if (code < 0 || code > 0xffff) {
@@ -180,7 +180,7 @@ Rcode_init(s_Rcode* const self, PyObject* args) {
return (-1);
}
ext_code = -1;
- } else if (PyArg_ParseTuple(args, "ll", &code, &ext_code)) {
+ } else if (PyArg_ParseTuple(args, "li", &code, &ext_code)) {
if (code < 0 || code > 0xff || ext_code < 0 || ext_code > 0xff) {
PyErr_SetString(PyExc_OverflowError, "Rcode out of range");
return (-1);
diff --git a/src/lib/dns/python/tests/message_python_test.py b/src/lib/dns/python/tests/message_python_test.py
index 0af7110..2850c8c 100644
--- a/src/lib/dns/python/tests/message_python_test.py
+++ b/src/lib/dns/python/tests/message_python_test.py
@@ -111,7 +111,7 @@ class MessageTest(unittest.TestCase):
self.assertRaises(InvalidParameter, self.r.set_header_flag, 0)
self.assertRaises(InvalidParameter, self.r.set_header_flag, 0x7000)
self.assertRaises(InvalidParameter, self.r.set_header_flag, 0x0800)
- # this would cause overflow and result in a "valid" flag
+ # this would cause overflow
self.assertRaises(OverflowError, self.r.set_header_flag, 0x10000)
self.assertRaises(OverflowError, self.r.set_header_flag, -1)
diff --git a/src/lib/dns/python/tests/name_python_test.py b/src/lib/dns/python/tests/name_python_test.py
index ce417bb..e0482a9 100644
--- a/src/lib/dns/python/tests/name_python_test.py
+++ b/src/lib/dns/python/tests/name_python_test.py
@@ -95,8 +95,7 @@ class NameTest(unittest.TestCase):
b = bytearray()
b += b'\x07example'*32 + b'\x03com\x00'
self.assertRaises(DNSMessageFORMERR, Name, b, 0)
- self.assertRaises(OverflowError, Name, b, -1)
- self.assertRaises(OverflowError, Name, b, 0x10000)
+ self.assertRaises(TypeError, Name, b, -1)
def test_at(self):
self.assertEqual(7, self.name1.at(0))
More information about the bind10-changes
mailing list