Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a54069c authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman
Browse files

staging: vc04_services: changen strncpy() to strscpy_pad()



[ Upstream commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf ]

gcc-14 warns about this strncpy() that results in a non-terminated
string for an overflow:

In file included from include/linux/string.h:369,
                 from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:20:
In function 'strncpy',
    inlined from 'create_component' at drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:940:2:
include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]

Change it to strscpy_pad(), which produces a properly terminated and
zero-padded string.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240313163712.224585-1-arnd@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: f37e76abd614 ("staging: vc04_services: fix information leak in create_component()")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 60cb8c4a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -921,7 +921,7 @@ static int create_component(struct vchiq_mmal_instance *instance,
	/* build component create message */
	m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
	m.u.component_create.client_component = component->client_component;
	strncpy(m.u.component_create.name, name,
	strscpy_pad(m.u.component_create.name, name,
		    sizeof(m.u.component_create.name));

	ret = send_synchronous_mmal_msg(instance, &m,