From owner-svn-src-head@FreeBSD.ORG Tue Sep 1 18:30:17 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF5671065676; Tue, 1 Sep 2009 18:30:17 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C49528FC12; Tue, 1 Sep 2009 18:30:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n81IUHot069088; Tue, 1 Sep 2009 18:30:17 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n81IUHAu069085; Tue, 1 Sep 2009 18:30:17 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200909011830.n81IUHAu069085@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 1 Sep 2009 18:30:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196740 - head/lib/libc/posix1e X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 18:30:18 -0000 Author: trasz Date: Tue Sep 1 18:30:17 2009 New Revision: 196740 URL: http://svn.freebsd.org/changeset/base/196740 Log: Fix regression introduced with NFSv4 ACL support - make acl_to_text(3) and acl_calc_mask(3) return error instead of crashing when acl passed to them is NULL. Submitted by: markus Reviewed by: rwatson MFC after: 3 days Modified: head/lib/libc/posix1e/acl_calc_mask.c head/lib/libc/posix1e/acl_to_text.c Modified: head/lib/libc/posix1e/acl_calc_mask.c ============================================================================== --- head/lib/libc/posix1e/acl_calc_mask.c Tue Sep 1 17:55:37 2009 (r196739) +++ head/lib/libc/posix1e/acl_calc_mask.c Tue Sep 1 18:30:17 2009 (r196740) @@ -50,12 +50,6 @@ acl_calc_mask(acl_t *acl_p) acl_t acl_new; int i, mask_mode, mask_num; - if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { - errno = EINVAL; - return (-1); - } - _acl_brand_as(*acl_p, ACL_BRAND_POSIX); - /* * (23.4.2.4) requires acl_p to point to a pointer to a valid ACL. * Since one of the primary reasons to use this function would be @@ -67,6 +61,13 @@ acl_calc_mask(acl_t *acl_p) errno = EINVAL; return (-1); } + + if (!_acl_brand_may_be(*acl_p, ACL_BRAND_POSIX)) { + errno = EINVAL; + return (-1); + } + _acl_brand_as(*acl_p, ACL_BRAND_POSIX); + acl_int = &(*acl_p)->ats_acl; if ((acl_int->acl_cnt < 3) || (acl_int->acl_cnt > ACL_MAX_ENTRIES)) { errno = EINVAL; Modified: head/lib/libc/posix1e/acl_to_text.c ============================================================================== --- head/lib/libc/posix1e/acl_to_text.c Tue Sep 1 17:55:37 2009 (r196739) +++ head/lib/libc/posix1e/acl_to_text.c Tue Sep 1 18:30:17 2009 (r196740) @@ -70,11 +70,6 @@ _posix1e_acl_to_text(acl_t acl, ssize_t if (buf == NULL) return(NULL); - if (acl == NULL) { - errno = EINVAL; - return(NULL); - } - acl_int = &acl->ats_acl; mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */ @@ -243,6 +238,11 @@ char * acl_to_text_np(acl_t acl, ssize_t *len_p, int flags) { + if (acl == NULL) { + errno = EINVAL; + return(NULL); + } + switch (_acl_brand(acl)) { case ACL_BRAND_POSIX: return (_posix1e_acl_to_text(acl, len_p, flags));