瀏覽代碼

ZOOKEEPER-1714 perl client segfaults if ZOO_READ_ACL_UNSAFE constant is used
(Botond Hejj via camille)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1495522 13f79535-47bb-0310-9956-ffa450edef68

Camille Fournier 12 年之前
父節點
當前提交
0b2c75f0b1
共有 3 個文件被更改,包括 23 次插入4 次删除
  1. 3 0
      CHANGES.txt
  2. 3 3
      src/contrib/zkperl/ZooKeeper.xs
  3. 17 1
      src/contrib/zkperl/t/50_access.t

+ 3 - 0
CHANGES.txt

@@ -530,6 +530,9 @@ IMPROVEMENTS:
 
   ZOOKEEPER-1643. Windows: fetch_and_add not 64bit-compatible, may not be
   correct (Erik Anderson via michim)
+  
+  ZOOKEEPER-1714 perl client segfaults if ZOO_READ_ACL_UNSAFE constant is used
+  (Botond Hejj via camille)
 
 Release 3.4.0 - 
 

+ 3 - 3
src/contrib/zkperl/ZooKeeper.xs

@@ -695,13 +695,13 @@ zk_acl_constant(alias=Nullch)
             alias = GvNAME(CvGV(cv));
         }
 
-        if (ix == 1 || strEQ(alias, "ZOO_OPEN_ACL_UNSAFE")) {
+        if (ix == 1 || (alias != NULL && strEQ(alias, "ZOO_OPEN_ACL_UNSAFE"))) {
             acl = ZOO_OPEN_ACL_UNSAFE;
         }
-        else if (ix == 2 || strEQ(alias, "ZOO_READ_ACL_UNSAFE")) {
+        else if (ix == 2 || (alias != NULL && strEQ(alias, "ZOO_READ_ACL_UNSAFE"))) {
             acl = ZOO_READ_ACL_UNSAFE;
         }
-        else if (ix == 3 || strEQ(alias, "ZOO_CREATOR_ALL_ACL")) {
+        else if (ix == 3 || (alias != NULL && strEQ(alias, "ZOO_CREATOR_ALL_ACL"))) {
             acl = ZOO_CREATOR_ALL_ACL;
         }
         else {

+ 17 - 1
src/contrib/zkperl/t/50_access.t

@@ -17,7 +17,7 @@
 # limitations under the License.
 
 use File::Spec;
-use Test::More tests => 38;
+use Test::More tests => 40;
 
 BEGIN { use_ok('Net::ZooKeeper', qw(:all)) };
 
@@ -51,6 +51,22 @@ SKIP: {
         $no_read_acl->[0]->{'perms'} == ZOO_PERM_ALL),
        '_zk_acl_constant(): returned default ACL');
 
+    my $zoo_read_acl_unsafe = ZOO_READ_ACL_UNSAFE;
+    ok((ref($zoo_read_acl_unsafe) eq 'ARRAY' and
+        @{$zoo_read_acl_unsafe} == 1 and
+        ref($zoo_read_acl_unsafe->[0]) eq 'HASH' and
+        keys(%{$zoo_read_acl_unsafe->[0]}) == 3 and
+        $zoo_read_acl_unsafe->[0]->{'perms'} == ZOO_PERM_READ),
+       '_zk_acl_constant(): returned good ACL');
+
+    my $zoo_creator_all_acl = ZOO_CREATOR_ALL_ACL;
+    ok((ref($zoo_creator_all_acl) eq 'ARRAY' and
+        @{$zoo_creator_all_acl} == 1 and
+        ref($zoo_creator_all_acl->[0]) eq 'HASH' and
+        keys(%{$zoo_creator_all_acl->[0]}) == 3 and
+        $zoo_creator_all_acl->[0]->{'perms'} == ZOO_PERM_ALL),
+       '_zk_acl_constant(): returned good ACL');
+
     $no_read_acl->[0]->{'perms'} &= ~ZOO_PERM_READ;
     is($no_read_acl->[0]->{'perms'}, ((ZOO_PERM_ALL) & ~ZOO_PERM_READ),
        'assign: altered default ACL');