intercept_fd_cb: store the passed fd in newfd, not fd

only affects the old BSD-style fd passing code, not POSIX-style.
This commit is contained in:
Todd C. Miller
2021-08-19 13:10:44 -06:00
parent d333f484ec
commit 5d3ab032f2

View File

@@ -579,8 +579,8 @@ intercept_fd_cb(int fd, int what, void *v)
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
#else
msg.msg_accrights = (caddr_t)&fd;
msg.msg_accrightslen = sizeof(fd);
msg.msg_accrights = (caddr_t)&newfd;
msg.msg_accrightslen = sizeof(newfd);
#endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */
switch (recvmsg(fd, &msg, 0)) {
@@ -616,7 +616,7 @@ intercept_fd_cb(int fd, int what, void *v)
}
memcpy(&newfd, CMSG_DATA(cmsg), sizeof(newfd));
#else
if (msg.msg_accrightslen != sizeof(fd)) {
if (msg.msg_accrightslen != sizeof(newfd)) {
sudo_warnx(U_("%s: missing message header"), __func__);
goto bad;
}