newgrp: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
bcb6ccf819
commit
994b3295c2
|
@ -123,7 +123,7 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
{
|
{
|
||||||
char **look;
|
char **look;
|
||||||
int notfound = 1;
|
int notfound = 1;
|
||||||
char *pwd, *xpwd;
|
char *pwd, *xpwd, *spwd;
|
||||||
|
|
||||||
if (getuid() == 0)
|
if (getuid() == 0)
|
||||||
/* root may do anything */
|
/* root may do anything */
|
||||||
|
@ -144,8 +144,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
* as in /etc/passwd */
|
* as in /etc/passwd */
|
||||||
|
|
||||||
/* check /etc/gshadow */
|
/* check /etc/gshadow */
|
||||||
if (!(pwd = get_gshadow_pwd(ge->gr_name)))
|
spwd = get_gshadow_pwd(ge->gr_name);
|
||||||
pwd = ge->gr_passwd;
|
pwd = spwd ? spwd : ge->gr_passwd;
|
||||||
|
|
||||||
if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) {
|
if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) {
|
||||||
char *cbuf = crypt(xpwd, pwd);
|
char *cbuf = crypt(xpwd, pwd);
|
||||||
|
@ -162,6 +162,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(spwd);
|
||||||
|
|
||||||
/* default to denial */
|
/* default to denial */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue