[PATCH] selftests/powerpc: Fix strncpy usage
Segher Boessenkool
segher at kernel.crashing.org
Fri Jun 22 09:18:56 AEST 2018
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
More information about the Linuxppc-dev
mailing list