s3:modules: Fix realloc with zero sized ACLs
authorAlexander Werth <alexander.werth@de.ibm.com>
Tue, 29 Oct 2013 15:20:04 +0000 (16:20 +0100)
committerDavid Disseldorp <ddiss@samba.org>
Wed, 30 Oct 2013 17:44:40 +0000 (18:44 +0100)
A realloc with size zero is similar to a free.
Since we return the number of acls that's not an error.

Signed-off-by: Alexander Werth <alexander.werth@de.ibm.com>
Reviewed-by: David Disseldorp <ddiss@samba.org>
source3/modules/nfs4_acls.c

index 500cb47..1366ba1 100644 (file)
@@ -336,7 +336,7 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
                mem_ctx, 2 * aclint->naces * sizeof(struct security_ace));
        if (nt_ace_list==NULL)
        {
-               DEBUG(10, ("talloc error"));
+               DEBUG(10, ("talloc error with %d aces", aclint->naces));
                errno = ENOMEM;
                return false;
        }
@@ -473,10 +473,12 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx,
                }
        }
 
-       nt_ace_list = (struct security_ace *)TALLOC_REALLOC(mem_ctx,
-                                       nt_ace_list,
-                                       good_aces * sizeof(struct security_ace));
-       if (nt_ace_list == NULL) {
+       nt_ace_list = (struct security_ace *)
+               TALLOC_REALLOC(mem_ctx, nt_ace_list,
+                                      good_aces * sizeof(struct security_ace));
+       /* returns a NULL ace list when good_aces is zero. */
+       if (good_aces && nt_ace_list == NULL) {
+               DEBUG(10, ("realloc error with %d aces", good_aces));
                errno = ENOMEM;
                return false;
        }