From: Stephen Hemminger <stephen@networkplumber.org>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: netdev@vger.kernel.org, dsahern@gmail.com,
Paul Wouters <pwouters@redhat.com>
Subject: Re: [PATCH iproute2] ip: xfrm: add NUL character to security context name before printing
Date: Mon, 8 Mar 2021 09:18:41 -0800 [thread overview]
Message-ID: <20210308091841.5d572cf1@hermes.local> (raw)
In-Reply-To: <11af39932b3896cf1a560059bcbd24194e7f33bd.1613473397.git.sd@queasysnail.net>
On Tue, 16 Feb 2021 17:50:58 +0100
Sabrina Dubroca <sd@queasysnail.net> wrote:
> +static void xfrm_sec_ctx_print(FILE *fp, struct rtattr *attr)
> +{
> + struct xfrm_user_sec_ctx *sctx;
> + char buf[65536] = {};
> +
> + fprintf(fp, "\tsecurity context ");
> +
> + if (RTA_PAYLOAD(attr) < sizeof(*sctx))
> + fprintf(fp, "(ERROR truncated)");
> +
> + sctx = RTA_DATA(attr);
> +
> + memcpy(buf, (char *)(sctx + 1), sctx->ctx_len);
> + fprintf(fp, "%s %s", buf, _SL_);
> +}
The copy buffer is not needed. Use the printf precision as
a mechanism instead.
fprintf(fp, "%.*s %s", sctx->ctx_len, (char *)(sctx + 1));
next prev parent reply other threads:[~2021-03-08 17:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 16:50 [PATCH iproute2] ip: xfrm: add NUL character to security context name before printing Sabrina Dubroca
2021-03-08 11:30 ` Sabrina Dubroca
2021-03-08 17:18 ` Stephen Hemminger [this message]
2021-03-09 15:44 ` [PATCH iproute2 v2] ip: xfrm: limit the length of the security context name when printing Sabrina Dubroca
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=20210308091841.5d572cf1@hermes.local \
--to=stephen@networkplumber.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pwouters@redhat.com \
--cc=sd@queasysnail.net \
/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).