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:
@@ -501,9 +501,9 @@ update_client_creds(struct client *c)
|
|||||||
#ifdef HAVE_GETPEERUCRED
|
#ifdef HAVE_GETPEERUCRED
|
||||||
/* Solaris 10 */
|
/* 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.uid = ucred_geteuid(peercred);
|
||||||
c->unixrights.gid = ucred_getegid(peercred);
|
c->unixrights.gid = ucred_getegid(peercred);
|
||||||
c->unixrights.pid = 0;
|
c->unixrights.pid = 0;
|
||||||
|
Reference in New Issue
Block a user