svn commit: r196862 - in stable/8/lib/libc: . posix1e stdio stdtime string

Edward Tomasz Napierala trasz at FreeBSD.org
Sat Sep 5 15:01:57 UTC 2009


Author: trasz
Date: Sat Sep  5 15:01:56 2009
New Revision: 196862
URL: http://svn.freebsd.org/changeset/base/196862

Log:
  MFC r196740:
  
  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
  Approved by:	re (kib)

Modified:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/posix1e/acl_calc_mask.c
  stable/8/lib/libc/posix1e/acl_to_text.c
  stable/8/lib/libc/stdio/asprintf.c   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/string/ffsll.c   (props changed)
  stable/8/lib/libc/string/flsll.c   (props changed)
  stable/8/lib/libc/string/wcpcpy.c   (props changed)
  stable/8/lib/libc/string/wcpncpy.c   (props changed)

Modified: stable/8/lib/libc/posix1e/acl_calc_mask.c
==============================================================================
--- stable/8/lib/libc/posix1e/acl_calc_mask.c	Sat Sep  5 13:32:05 2009	(r196861)
+++ stable/8/lib/libc/posix1e/acl_calc_mask.c	Sat Sep  5 15:01:56 2009	(r196862)
@@ -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: stable/8/lib/libc/posix1e/acl_to_text.c
==============================================================================
--- stable/8/lib/libc/posix1e/acl_to_text.c	Sat Sep  5 13:32:05 2009	(r196861)
+++ stable/8/lib/libc/posix1e/acl_to_text.c	Sat Sep  5 15:01:56 2009	(r196862)
@@ -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));


More information about the svn-src-stable-8 mailing list