zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1212161 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/c/src/zookeeper.c src/c/tests/TestClient.cc
Date Thu, 08 Dec 2011 22:03:35 GMT
Author: mahadev
Date: Thu Dec  8 22:03:35 2011
New Revision: 1212161

URL: http://svn.apache.org/viewvc?rev=1212161&view=rev
Log:
ZOOKEEPER-1305. zookeeper.c:prepend_string func can dereference null ptr. (Daniel Lescohier
via mahadev) - Merging r1212153 from trunk.

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/c/src/zookeeper.c
    zookeeper/branches/branch-3.4/src/c/tests/TestClient.cc

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1212161&r1=1212160&r2=1212161&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Thu Dec  8 22:03:35 2011
@@ -6,6 +6,8 @@ BUGFIXES: 
 
   ZOOKEEPER-1311. ZooKeeper test jar is broken (Ivan Kelly via phunt)
 
+  ZOOKEEPER-1305. zookeeper.c:prepend_string func can dereference null ptr.
+  (Daniel Lescohier via mahadev)
 
 Release 3.4.0 - 2011-10-25
 

Modified: zookeeper/branches/branch-3.4/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/zookeeper.c?rev=1212161&r1=1212160&r2=1212161&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/c/src/zookeeper.c (original)
+++ zookeeper/branches/branch-3.4/src/c/src/zookeeper.c Thu Dec  8 22:03:35 2011
@@ -871,7 +871,7 @@ void free_duplicate_path(const char *fre
 */
 static char* prepend_string(zhandle_t *zh, const char* client_path) {
     char *ret_str;
-    if (zh->chroot == NULL)
+    if (zh == NULL || zh->chroot == NULL)
         return (char *) client_path;
     // handle the chroot itself, client_path = "/"
     if (strlen(client_path) == 1) {

Modified: zookeeper/branches/branch-3.4/src/c/tests/TestClient.cc
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/tests/TestClient.cc?rev=1212161&r1=1212160&r2=1212161&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/c/tests/TestClient.cc (original)
+++ zookeeper/branches/branch-3.4/src/c/tests/TestClient.cc Thu Dec  8 22:03:35 2011
@@ -792,6 +792,10 @@ public:
         zk_ch = createchClient(&ctx_ch, "127.0.0.1:22181/testch1/mahadev");
         CPPUNIT_ASSERT(zk_ch != NULL);
         zk = createClient(&ctx);
+        // first test with a NULL zk handle, make sure client library does not
+        // dereference a null pointer, but instead returns ZBADARGUMENTS
+        rc = zoo_create(NULL, "/testch1", "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
+        CPPUNIT_ASSERT_EQUAL((int) ZBADARGUMENTS, rc);
         rc = zoo_create(zk, "/testch1", "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
         CPPUNIT_ASSERT_EQUAL((int) ZOK, rc);
         rc = zoo_create(zk, "/testch1/mahadev", data, 7, &ZOO_OPEN_ACL_UNSAFE, 0, 0,
0);



Mime
View raw message