]> asedeno.scripts.mit.edu Git - linux.git/commit
powerpc/64: Fix strncpy() related build failures with GCC 8.1
authorChristophe Leroy <christophe.leroy@c-s.fr>
Tue, 29 May 2018 06:03:53 +0000 (06:03 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 3 Jun 2018 10:40:24 +0000 (20:40 +1000)
commitc95998811807d897ca112ea62d66716ed733d058
treeb7b0c54abccf23fa23417cb1d2a89f83c51754a4
parent2135a6ec3eb9633727f657f020e27048fb7c105a
powerpc/64: Fix strncpy() related build failures with GCC 8.1

GCC 8.1 warns about possible string truncation:

  arch/powerpc/kernel/nvram_64.c:1042:2: error: 'strncpy' specified
  bound 12 equals destination size [-Werror=stringop-truncation]
    strncpy(new_part->header.name, name, 12);

  arch/powerpc/platforms/ps3/repository.c:106:2: error: 'strncpy'
  output truncated before terminating nul copying 8 bytes from a
  string of the same length [-Werror=stringop-truncation]
    strncpy((char *)&n, text, 8);

Fix it by using memcpy(). To make that safe we need to ensure the
destination is pre-zeroed. Use kzalloc() in the nvram code and
initialise the u64 to zero in the ps3 code.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
[mpe: Use kzalloc() in the nvram code, flesh out change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/nvram_64.c
arch/powerpc/platforms/ps3/repository.c