From a6bc2fd0d1df3746d7ae3d987765b346feee2bd8 Mon Sep 17 00:00:00 2001 From: Alexander Werth Date: Tue, 29 Oct 2013 16:20:04 +0100 Subject: s3:modules: Fix realloc with zero sized ACLs 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 Reviewed-by: David Disseldorp --- source3/modules/nfs4_acls.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c index 500cb4772a..1366ba15c3 100644 --- a/source3/modules/nfs4_acls.c +++ b/source3/modules/nfs4_acls.c @@ -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; } -- cgit