Subject: Re: [PATCH] selftests/powerpc: Fix strncpy usage

From: Segher Boessenkool <[email-masked]>
Date: Thu, 21 Jun 2018 18:18:56 -0500

On Wed, Jun 20, 2018 at 07:51:11PM -0300, Breno Leitao wrote:
> -	strncpy(prog, argv[0], strlen(argv[0]));
> +	strncpy(prog, argv[0], sizeof(prog) - 1);

	strncpy(prog, argv[0], sizeof prog);
	if (prog[sizeof prog - 1])
		scream_bloody_murder();

Silently using the wrong data is a worse habit than not checking for
overflows ;-)

Segher