Skip to content

Commit

Permalink
libnl: don't use out-of-scope buffer in nl_send_iovec()
Browse files Browse the repository at this point in the history
The control message buffer is desclared in the if body
and then this buffer is used outside.

http://lists.infradead.org/pipermail/libnl/2015-November/002013.html

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
  • Loading branch information
avagin authored and thom311 committed Nov 24, 2015
1 parent ef32af0 commit 7bbd09d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nl.c
Expand Up @@ -384,6 +384,7 @@ int nl_send_iovec(struct nl_sock *sk, struct nl_msg *msg, struct iovec *iov, uns
.msg_iov = iov,
.msg_iovlen = iovlen,
};
char buf[CMSG_SPACE(sizeof(struct ucred))];

/* Overwrite destination if specified in the message itself, defaults
* to the peer address of the socket.
Expand All @@ -395,7 +396,6 @@ int nl_send_iovec(struct nl_sock *sk, struct nl_msg *msg, struct iovec *iov, uns
/* Add credentials if present. */
creds = nlmsg_get_creds(msg);
if (creds != NULL) {
char buf[CMSG_SPACE(sizeof(struct ucred))];
struct cmsghdr *cmsg;

hdr.msg_control = buf;
Expand Down

0 comments on commit 7bbd09d

Please sign in to comment.