On Tue, 16 Feb 2021 17:50:58 +0100
Sabrina Dubroca <[email protected]> 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));