libcli:security: Return early if there are no aces to duplicate
authorAndreas Schneider <asn@samba.org>
Wed, 12 Dec 2018 09:21:25 +0000 (10:21 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 12 Dec 2018 21:18:52 +0000 (22:18 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Dec 12 22:18:52 CET 2018 on sn-devel-144

libcli/security/security_descriptor.c

index 02c3212..7b7a13d 100644 (file)
@@ -67,15 +67,20 @@ struct security_acl *security_acl_dup(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
+       *nacl = (struct security_acl) {
+               .revision = oacl->revision,
+               .size     = oacl->size,
+               .num_aces = oacl->num_aces,
+       };
+       if (nacl->num_aces == 0) {
+               return nacl;
+       }
+
        nacl->aces = (struct security_ace *)talloc_memdup (nacl, oacl->aces, sizeof(struct security_ace) * oacl->num_aces);
-       if ((nacl->aces == NULL) && (oacl->num_aces > 0)) {
+       if (nacl->aces == NULL) {
                goto failed;
        }
 
-       nacl->revision = oacl->revision;
-       nacl->size = oacl->size;
-       nacl->num_aces = oacl->num_aces;
-       
        return nacl;
 
  failed: