From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: "Pali Rohár" <pali@kernel.org>,
"Michael Kerrisk" <mtk.manpages@gmail.com>
Cc: linux-man@vger.kernel.org
Subject: Re: [PATCH] sock_diag.7: Fix recvmsg() usage in the example
Date: Sun, 17 Jan 2021 17:08:09 +0100 [thread overview]
Message-ID: <ef7ce97c-2d9c-adb9-b40e-322f3107ff50@gmail.com> (raw)
In-Reply-To: <20210116184554.30730-1-pali@kernel.org>
On 1/16/21 7:45 PM, Pali Rohár wrote:
> The msg_name field for recvmsg() call points to a caller-allocated buffer
> nladdr that is used to return the source address of the (netlink) socket.
>
> As recvmsg() does not read this buffer and fills it for a caller, do not
> initialize it and instead check its value in the example.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Hi Pali,
Patch applied.
Thanks,
Alex
> ---
> man7/sock_diag.7 | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/man7/sock_diag.7 b/man7/sock_diag.7
> index 91ccf3ac5..191e6ac49 100644
> --- a/man7/sock_diag.7
> +++ b/man7/sock_diag.7
> @@ -753,9 +753,7 @@ static int
> receive_responses(int fd)
> {
> long buf[8192 / sizeof(long)];
> - struct sockaddr_nl nladdr = {
> - .nl_family = AF_NETLINK
> - };
> + struct sockaddr_nl nladdr;
> struct iovec iov = {
> .iov_base = buf,
> .iov_len = sizeof(buf)
> @@ -782,6 +780,11 @@ receive_responses(int fd)
> if (ret == 0)
> return 0;
>
> + if (nladdr.nl_family != AF_NETLINK) {
> + fputs("!AF_NETLINK\en", stderr);
> + return \-1;
> + }
> +
> const struct nlmsghdr *h = (struct nlmsghdr *) buf;
>
> if (!NLMSG_OK(h, ret)) {
>
next prev parent reply other threads:[~2021-01-17 16:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-16 18:45 [PATCH] sock_diag.7: Fix recvmsg() usage in the example Pali Rohár
2021-01-17 16:08 ` Alejandro Colomar (man-pages) [this message]
2021-01-24 15:10 Alejandro Colomar
2021-01-25 7:02 ` Michael Kerrisk (man-pages)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef7ce97c-2d9c-adb9-b40e-322f3107ff50@gmail.com \
--to=alx.manpages@gmail.com \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=pali@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).