Avoid clobbering the gecos field, as we intend to use the original later.
PR: bin/50563
This commit is contained in:
parent
3ea200b250
commit
f8704b9d92
@ -109,7 +109,7 @@ static int
|
|||||||
display(const char *tfn, struct passwd *pw)
|
display(const char *tfn, struct passwd *pw)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *bp, *p;
|
char *bp, *gecos, *p;
|
||||||
|
|
||||||
if ((fp = fopen(tfn, "w")) == NULL) {
|
if ((fp = fopen(tfn, "w")) == NULL) {
|
||||||
warn("%s", tfn);
|
warn("%s", tfn);
|
||||||
@ -151,8 +151,13 @@ display(const char *tfn, struct passwd *pw)
|
|||||||
(void)fprintf(fp, "Shell: %s\n",
|
(void)fprintf(fp, "Shell: %s\n",
|
||||||
*pw->pw_shell ? pw->pw_shell : _PATH_BSHELL);
|
*pw->pw_shell ? pw->pw_shell : _PATH_BSHELL);
|
||||||
else
|
else
|
||||||
list[E_SHELL].restricted = 1;
|
list[E_SHELL].restricted = 1;
|
||||||
bp = pw->pw_gecos;
|
|
||||||
|
if ((bp = gecos = strdup(pw->pw_gecos)) == NULL) {
|
||||||
|
warn(NULL);
|
||||||
|
fclose(fp);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
p = strsep(&bp, ",");
|
p = strsep(&bp, ",");
|
||||||
p = strdup(p ? p : "");
|
p = strdup(p ? p : "");
|
||||||
@ -183,6 +188,8 @@ display(const char *tfn, struct passwd *pw)
|
|||||||
if (!list[E_OTHER].restricted || master_mode)
|
if (!list[E_OTHER].restricted || master_mode)
|
||||||
(void)fprintf(fp, "Other information: %s\n", bp);
|
(void)fprintf(fp, "Other information: %s\n", bp);
|
||||||
|
|
||||||
|
free(gecos);
|
||||||
|
|
||||||
(void)fchown(fileno(fp), getuid(), getgid());
|
(void)fchown(fileno(fp), getuid(), getgid());
|
||||||
(void)fclose(fp);
|
(void)fclose(fp);
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user