git: 85c9d36497fc - main - acl_equiv_mode_np: zero mode on just inited ACL
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 03 Jan 2024 16:50:46 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=85c9d36497fc3a6e82932e1cb46df2670a0b9e64
commit 85c9d36497fc3a6e82932e1cb46df2670a0b9e64
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-01-03 16:34:39 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-01-03 16:34:39 +0000
acl_equiv_mode_np: zero mode on just inited ACL
You can't return 0 and not write the mode if mode_p is non-NULL. That
violates the API contract and in common usage leaves stack trash in
*mode_p.
The acl_equiv_mode_test test passed by accident.
Reviewed by: kevans, markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43278
---
lib/libc/posix1e/acl_equiv_mode_np.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/libc/posix1e/acl_equiv_mode_np.c b/lib/libc/posix1e/acl_equiv_mode_np.c
index b3bf5280493a..333b010541ee 100644
--- a/lib/libc/posix1e/acl_equiv_mode_np.c
+++ b/lib/libc/posix1e/acl_equiv_mode_np.c
@@ -49,7 +49,7 @@ acl_equiv_mode_np(acl_t acl, mode_t *mode_p)
/* Linux returns 0 for ACL returned by acl_init() */
if (_acl_brand(acl) == ACL_BRAND_UNKNOWN && acl->ats_acl.acl_cnt == 0)
- return (0);
+ goto done;
// TODO: Do we want to handle ACL_BRAND_NFS4 in this function? */
if (_acl_brand(acl) != ACL_BRAND_POSIX)
@@ -91,6 +91,7 @@ acl_equiv_mode_np(acl_t acl, mode_t *mode_p)
}
}
+done:
if (mode_p != NULL)
*mode_p = ret_mode;