mirror of
https://github.com/torvalds/linux.git
synced 2026-10-16 12:50:02 +02:00
GCC fails to build ps3_defconfig with the following errors:
arch/powerpc/platforms/ps3/repository.c: In function ‘make_first_field.constprop’:
arch/powerpc/platforms/ps3/repository.c:78:9: error: ‘strnlen’ specified bound 8 exceeds source size 3 [-Werror=stringop-overread]
78 | memcpy((char *)&n, text, strnlen(text, sizeof(n)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/platforms/ps3/repository.c: In function ‘make_first_field.constprop’:
arch/powerpc/platforms/ps3/repository.c:78:9: error: ‘strnlen’ specified bound 8 exceeds source size 4 [-Werror=stringop-overread]
78 | memcpy((char *)&n, text, strnlen(text, sizeof(n)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The current use of strnlen(text, sizeof(n)) triggers -Wstringop-overread
when text is a short string literal that is smaller than sizeof(n), such
as "bi" or "bus". Use strlen(text) instead and clamp the copy length to
sizeof(n) before memcpy().
Drop the redundant char * cast while at it.
Fixes:
|
||
|---|---|---|
| .. | ||
| device-init.c | ||
| exports.c | ||
| gelic_udbg.c | ||
| htab.c | ||
| hvcall.S | ||
| interrupt.c | ||
| Kconfig | ||
| Makefile | ||
| mm.c | ||
| os-area.c | ||
| platform.h | ||
| repository.c | ||
| setup.c | ||
| smp.c | ||
| spu.c | ||
| system-bus.c | ||
| time.c | ||