diff options
author | trasz <trasz@FreeBSD.org> | 2010-03-28 17:29:15 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2010-03-28 17:29:15 +0000 |
commit | b49ccfb35d3b2ee3739360a5fcbbc55ac5bcc70b (patch) | |
tree | f7442a82c40488ab5fe34fffca1448c3f19f84c7 | |
parent | 45b79f9effb151849b5c1a47c4774c96dd72d1d4 (diff) | |
download | FreeBSD-src-b49ccfb35d3b2ee3739360a5fcbbc55ac5bcc70b.zip FreeBSD-src-b49ccfb35d3b2ee3739360a5fcbbc55ac5bcc70b.tar.gz |
Make acl_to_text_np(3) not crash on long group or user names in NFSv4 ACLs.
PR: amd64/145091
MFC after: 2 weeks
-rw-r--r-- | lib/libc/posix1e/acl_to_text_nfs4.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/libc/posix1e/acl_to_text_nfs4.c b/lib/libc/posix1e/acl_to_text_nfs4.c index 3adbfb4..5d0aa31 100644 --- a/lib/libc/posix1e/acl_to_text_nfs4.c +++ b/lib/libc/posix1e/acl_to_text_nfs4.c @@ -167,7 +167,7 @@ format_additional_id(char *str, size_t size, const acl_entry_t entry) static int format_entry(char *str, size_t size, const acl_entry_t entry, int flags) { - size_t off = 0, padding_length, maximum_who_field_length = 18; + size_t off = 0, min_who_field_length = 18; acl_permset_t permset; acl_flagset_t flagset; int error, len; @@ -188,12 +188,9 @@ format_entry(char *str, size_t size, const acl_entry_t entry, int flags) if (error) return (error); len = strlen(buf); - padding_length = maximum_who_field_length - len; - if (padding_length > 0) { - memset(str, ' ', padding_length); - off += padding_length; - } - off += snprintf(str + off, size - off, "%s:", buf); + if (len < min_who_field_length) + len = min_who_field_length; + off += snprintf(str + off, size - off, "%*s:", len, buf); error = _nfs4_format_access_mask(buf, sizeof(buf), *permset, flags & ACL_TEXT_VERBOSE); |