Author: henry
Date: Fri Apr 30 23:02:52 2010
New Revision: 939869
URL: http://svn.apache.org/viewvc?rev=939869&view=rev
Log:
ZOOKEEPER-758. zkpython segfaults on invalid acl with missing key
Modified:
hadoop/zookeeper/branches/branch-3.3/CHANGES.txt
hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/c/zookeeper.c
hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/test/acl_test.py
Modified: hadoop/zookeeper/branches/branch-3.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.3/CHANGES.txt?rev=939869&r1=939868&r2=939869&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.3/CHANGES.txt (original)
+++ hadoop/zookeeper/branches/branch-3.3/CHANGES.txt Fri Apr 30 23:02:52 2010
@@ -33,6 +33,9 @@ BUGFIXES:
ZOOKEEPER-750. move maven artifacts into "dist-maven" subdir of the
release (package target) (phunt via henryr)
+ ZOOKEEPER-758. zkpython segfaults on invalid acl with missing key
+ (Kapil Thangavelu via henryr)
+
Release 3.3.0 - 2010-03-24
Non-backward compatible changes:
Modified: hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/c/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/c/zookeeper.c?rev=939869&r1=939868&r2=939869&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/c/zookeeper.c (original)
+++ hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/c/zookeeper.c Fri Apr 30
23:02:52 2010
@@ -286,8 +286,9 @@ PyObject *build_string_vector(const stru
/* Returns 1 if the PyObject is a valid representation of an ACL, and
0 otherwise. */
-int check_is_acl(PyObject *o) {
+int check_is_acl(PyObject *o) {
int i;
+ PyObject *entry;
if (o == NULL) {
return 0;
}
@@ -295,10 +296,26 @@ int check_is_acl(PyObject *o) {
return 0;
}
for (i=0;i<PyList_Size(o);++i) {
- if (!PyDict_Check(PyList_GetItem(o,i))) {
+ PyObject *element = PyList_GetItem(o,i);
+ if (!PyDict_Check(element)) {
+ return 0;
+ }
+ entry = PyDict_GetItemString( element, "perms" );
+ if (entry == Py_None) {
+ return 0;
+ }
+
+ entry = PyDict_GetItemString( element, "scheme" );
+ if (entry == Py_None) {
+ return 0;
+ }
+
+ entry = PyDict_GetItemString( element, "id" );
+ if (entry == Py_None) {
return 0;
}
}
+
return 1;
}
Modified: hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/test/acl_test.py
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/test/acl_test.py?rev=939869&r1=939868&r2=939869&view=diff
==============================================================================
--- hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/test/acl_test.py (original)
+++ hadoop/zookeeper/branches/branch-3.3/src/contrib/zkpython/src/test/acl_test.py Fri Apr
30 23:02:52 2010
@@ -85,5 +85,25 @@ class ACLTest(zktestbase.TestBase):
acls = zookeeper.get_acl(self.handle, "/zk-python-aacltest")
self.assertEqual(acls[1], [ZOO_ACL_READ], "Wrong ACL returned from get when aset")
+ def test_invalid_acl(self):
+ self.assertRaises(zookeeper.InvalidACLException,
+ zookeeper.create,
+ self.handle,
+ "/zk-python-aclverifytest",
+ "",
+ None,
+ zookeeper.EPHEMERAL)
+
+ def test_invalid_acl2(self):
+ """Verify all required keys are present in the ACL."""
+ invalid_acl = [{"schema": "digest", "id": "zebra"}],
+ self.assertRaises(zookeeper.InvalidACLException,
+ zookeeper.create,
+ self.handle,
+ "/zk-python-aclverifytest",
+ "",
+ invalid_acl,
+ zookeeper.EPHEMERAL))
+
if __name__ == '__main__':
unittest.main()
|