mirror of https://github.com/torvalds/linux.git
gcc-10 warns about a strncpy() that does not enforce zero-termination:
In file included from include/linux/string.h:369,
from drivers/staging/greybus/fw-management.c:9:
In function 'strncpy',
inlined from 'fw_mgmt_backend_fw_update_operation' at drivers/staging/greybus/fw-management.c:306:2:
include/linux/fortify-string.h:108:30: error: '__builtin_strncpy' specified bound 10 equals destination size [-Werror=stringop-truncation]
108 | #define __underlying_strncpy __builtin_strncpy
| ^
include/linux/fortify-string.h:187:9: note: in expansion of macro '__underlying_strncpy'
187 | return __underlying_strncpy(p, q, size);
| ^~~~~~~~~~~~~~~~~~~~
For some reason, I cannot reproduce this with gcc-9 or gcc-11, and I only
get a warning for one of the four related strncpy()s, so I'm not
sure what's going on.
Change all four to strscpy_pad(), which is the safest replacement here,
as it avoids ending up with uninitialized stack data in the tag name.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Link: https://github.com/KSPP/linux/issues/90 [1]
Link: https://lore.kernel.org/r/20240408194821.3183462-3-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||
|---|---|---|
| .. | ||
| Documentation | ||
| Kconfig | ||
| Makefile | ||
| TODO | ||
| arche-apb-ctrl.c | ||
| arche-platform.c | ||
| arche_platform.h | ||
| audio_apbridgea.c | ||
| audio_apbridgea.h | ||
| audio_codec.c | ||
| audio_codec.h | ||
| audio_gb.c | ||
| audio_helper.c | ||
| audio_helper.h | ||
| audio_manager.c | ||
| audio_manager.h | ||
| audio_manager_module.c | ||
| audio_manager_private.h | ||
| audio_manager_sysfs.c | ||
| audio_module.c | ||
| audio_topology.c | ||
| authentication.c | ||
| bootrom.c | ||
| camera.c | ||
| firmware.h | ||
| fw-core.c | ||
| fw-download.c | ||
| fw-management.c | ||
| gb-camera.h | ||
| gbphy.c | ||
| gbphy.h | ||
| gpio.c | ||
| greybus_authentication.h | ||
| greybus_firmware.h | ||
| hid.c | ||
| i2c.c | ||
| light.c | ||
| log.c | ||
| loopback.c | ||
| power_supply.c | ||
| pwm.c | ||
| raw.c | ||
| sdio.c | ||
| spi.c | ||
| spilib.c | ||
| spilib.h | ||
| uart.c | ||
| usb.c | ||
| vibrator.c | ||