Fix empty ACLs with nfs4 vfs module

David Disseldorp ddiss at suse.de
Wed Oct 30 07:58:12 MDT 2013


Hi Alexander,

Your changes look good. One minor comment...

On Wed, 30 Oct 2013 13:45:21 +0100
Alexander Werth <werth at linux.vnet.ibm.com> wrote:

> -	nt_ace_list = (struct security_ace *)TALLOC_REALLOC(mem_ctx,
> -					nt_ace_list,
> -					good_aces * sizeof(struct security_ace));
> +	nt_ace_list = (struct security_ace *)
> +		TALLOC_REALLOC(mem_ctx, nt_ace_list,
> +			       good_aces * sizeof(struct security_ace));
> +	if (good_aces == 0) /* realloc to zero size is a free.*/
> +		nt_ace_list = (struct security_ace *)TALLOC_SIZE(mem_ctx, 0);
>  	if (nt_ace_list == NULL) {
> +		DEBUG(10, ("realloc error with %d aces", good_aces));
>  		errno = ENOMEM;
>  		return false;
>  	}

I'd prefer an explicit TALLOC_FREE(), and return a NULL nt_ace_list in
such a case. The subsequent make_sec_acl() call doesn't require a valid
ptr when num_aces == 0. e.g.

 476         if (good_aces == 0) {
 477                 /* no aces, return NULL list */
 478                 TALLOC_FREE(nt_ace_list);
 479         } else {
 480                 nt_ace_list = (struct security_ace *)
 481                         TALLOC_REALLOC(mem_ctx, nt_ace_list,
 482                                        good_aces * sizeof(struct security_ace));
 483                 if (nt_ace_list == NULL) {
 484                         DEBUG(10, ("realloc error with %d aces", good_aces));
 485                         errno = ENOMEM;
 486                         return false;
 487                 }
 488         }
 489 
 490         *ppnt_ace_list = nt_ace_list;
 491         *pgood_aces = good_aces;

Cheers, David


More information about the samba-technical mailing list