getfacl: Don't trust length of incoming user/groupname

Fixes Coverity CIDs 60079 and 60080

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2016-10-23 16:52:28 +02:00
parent cf01b8f029
commit 7d5af6f0ba

View File

@ -40,7 +40,7 @@ username (uid_t uid)
struct passwd *pw;
if ((pw = getpwuid (uid)))
strcpy (ubuf, pw->pw_name);
snprintf (ubuf, sizeof ubuf, "%s", pw->pw_name);
else
sprintf (ubuf, "%lu <unknown>", (unsigned long)uid);
return ubuf;
@ -53,7 +53,7 @@ groupname (gid_t gid)
struct group *gr;
if ((gr = getgrgid (gid)))
strcpy (gbuf, gr->gr_name);
snprintf (gbuf, sizeof gbuf, "%s", gr->gr_name);
else
sprintf (gbuf, "%lu <unknown>", (unsigned long)gid);
return gbuf;