tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so that things properly aligned. Otherwise we might end up at an unaligned address and the counting goes all wrong, possibly making the kernel refuse our buffers. Also, let's make sure we initialize the control buffers to zero when sending, but leave them uninitialized when reading. Both the alignment and the initialization thing is mentioned in the cmsg(3) man page.
This commit is contained in:
@@ -859,13 +859,10 @@ int ask_password_agent(
|
||||
pollfd[FD_INOTIFY].events = POLLIN;
|
||||
|
||||
for (;;) {
|
||||
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
|
||||
char passphrase[LINE_MAX+1];
|
||||
struct iovec iovec;
|
||||
struct ucred *ucred;
|
||||
union {
|
||||
struct cmsghdr cmsghdr;
|
||||
uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
|
||||
} control;
|
||||
ssize_t n;
|
||||
int k;
|
||||
usec_t t;
|
||||
@@ -917,7 +914,6 @@ int ask_password_agent(
|
||||
|
||||
iovec = IOVEC_MAKE(passphrase, sizeof(passphrase));
|
||||
|
||||
zero(control);
|
||||
struct msghdr msghdr = {
|
||||
.msg_iov = &iovec,
|
||||
.msg_iovlen = 1,
|
||||
|
||||
Reference in New Issue
Block a user