IPC: use getpeerucred() API correctly (#382)

The ucred_t argument must be initialized to zero otherwise it is assumed to
point to allocated memory. Also, the logic is inverted: getpeerucred()
returns zero on success, not failure.
This commit is contained in:
Luke Howard
2018-05-12 14:40:56 +10:00
parent bd2c2eb8bd
commit 0c51e7c6ab

View File

@@ -501,9 +501,9 @@ update_client_creds(struct client *c)
#ifdef HAVE_GETPEERUCRED
/* Solaris 10 */
{
ucred_t *peercred;
ucred_t *peercred = NULL;
if (getpeerucred(c->fd, &peercred) != 0) {
if (getpeerucred(c->fd, &peercred) == 0) {
c->unixrights.uid = ucred_geteuid(peercred);
c->unixrights.gid = ucred_getegid(peercred);
c->unixrights.pid = 0;