Skip to content

Commit 10c14a1

Browse files
einval22wlallemand
authored andcommitted
MINOR: proto_sockpair: send_fd_uxst: init iobuf, cmsghdr, cmsgbuf to zeros
In master-worker mode, worker process uses now send_fd_uxst() to send '_send_status' command to master. Since refactoring, this started to trigger the following Valgrind reports: ==810584== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==810584== at 0x4AAC99D: __libc_sendmsg (sendmsg.c:28) ==810584== by 0x4AAC99D: sendmsg (sendmsg.c:25) ==810584== by 0x56350F: send_fd_uxst (proto_sockpair.c:271) ==810584== by 0x3AA25C: main (haproxy.c:4151) ==810584== Address 0x1ffefffbfe is on thread 1's stack ==810584== in frame #1, created by send_fd_uxst (proto_sockpair.c:241) ==810584== ==810584== Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s) ==810584== at 0x4AAC99D: __libc_sendmsg (sendmsg.c:28) ==810584== by 0x4AAC99D: sendmsg (sendmsg.c:25) ==810584== by 0x56350F: send_fd_uxst (proto_sockpair.c:271) ==810584== by 0x3AA25C: main (haproxy.c:4151) ==810584== Address 0x1ffefffc14 is on thread 1's stack ==810584== in frame #1, created by send_fd_uxst (proto_sockpair.c:241) ==810584== So, let's initialize with zeros all buffers, which are passed to sendmsg syscall(), used in send_fd_uxst() to avoid these Valgrind messages. They increase Valgrind output and could make unnoticeable some other, more important reports.
1 parent 7fb98e8 commit 10c14a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/proto_sockpair.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
239239
*/
240240
int send_fd_uxst(int fd, int send_fd)
241241
{
242-
char iobuf[2];
242+
char iobuf[2] = {0};
243243
struct iovec iov;
244244
struct msghdr msghdr;
245245

246-
char cmsgbuf[CMSG_SPACE(sizeof(int))];
247-
char buf[CMSG_SPACE(sizeof(int))];
246+
char cmsgbuf[CMSG_SPACE(sizeof(int))] = {0};
247+
char buf[CMSG_SPACE(sizeof(int))] = {0};
248248
struct cmsghdr *cmsg = (void *)buf;
249249

250250
int *fdptr;

0 commit comments

Comments
 (0)