]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
staging: vc04_services: changen strncpy() to strscpy_pad()
authorArnd Bergmann <arnd@arndb.de>
Wed, 13 Mar 2024 16:36:56 +0000 (17:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:32 +0000 (16:19 +0200)
commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf upstream.

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: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240313163712.224585-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c

index 76d3f03999647550de7f01e6b524dee1e2eaa1cb..75d9b24a7cb49ee64b86a2408976160cebc728aa 100644 (file)
@@ -940,8 +940,8 @@ 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,
-               sizeof(m.u.component_create.name));
+       strscpy_pad(m.u.component_create.name, name,
+                   sizeof(m.u.component_create.name));
 
        ret = send_synchronous_mmal_msg(instance, &m,
                                        sizeof(m.u.component_create),