]> Savannah Git Hosting - gnulib.git/commitdiff
file-has-acl: don’t access freed storage
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 12 May 2023 19:23:49 +0000 (12:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 12 May 2023 19:24:50 +0000 (12:24 -0700)
Fix typo in previous patch, by not accessing freed storage
in the unusual case where the statck buffer is not large enough.

lib/file-has-acl.c

index 1edcd2cbd6c5c243c3486e9a103963206e9d07de..38bc806dc49662a7982d8b320e07296a6a603629 100644 (file)
@@ -200,11 +200,13 @@ file_has_acl (char const *name, struct stat const *sb)
               || (S_ISDIR (sb->st_mode)
                   && have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT,
                                  listbuf, listsize))));
+      bool nfsv4_acl_but_no_posix_acl
+        = ret == 0 && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize);
       free (heapbuf);
 
       /* If there is an NFSv4 ACL but no POSIX ACL, follow up with a
          getxattr syscall to see whether the NFSv4 ACL is nontrivial.  */
-      if (ret == 0 && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize))
+      if (nfsv4_acl_but_no_posix_acl)
         {
           ret = getxattr (name, XATTR_NAME_NFSV4_ACL,
                           stackbuf.xattr, sizeof stackbuf.xattr);