From: Paul Eggert Date: Fri, 12 May 2023 19:23:49 +0000 (-0700) Subject: file-has-acl: don’t access freed storage X-Git-Tag: v1.0~1338 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f01d8792778b637f7464533ac019e42f58adb310;p=gnulib.git file-has-acl: don’t access freed storage Fix typo in previous patch, by not accessing freed storage in the unusual case where the statck buffer is not large enough. --- diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c index 1edcd2cbd6..38bc806dc4 100644 --- a/lib/file-has-acl.c +++ b/lib/file-has-acl.c @@ -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);