lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 8 Mar 2021 09:18:41 -0800
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Sabrina Dubroca <sd@...asysnail.net>
Cc:     netdev@...r.kernel.org, dsahern@...il.com,
        Paul Wouters <pwouters@...hat.com>
Subject: Re: [PATCH iproute2] ip: xfrm: add NUL character to security
 context name before printing

On Tue, 16 Feb 2021 17:50:58 +0100
Sabrina Dubroca <sd@...asysnail.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));

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ