accessibility: speakup: refactor deprecated strcpy

strcpy() is deprecated, use strscpy() instead.

As strcpy() performs no bounds checking on the destination buffer. This
could result in buffer overflow. The safe replacement is strscpy() [1][2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]

Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
Reviewed-by: Samuel thibault <samuel.thibault@ens-lyon.org>
Link: https://patch.msgid.link/20260829164945.2691317-2-samuel.thibault@ens-lyon.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ajith P V 2026-08-29 18:49:44 +02:00 committed by Greg Kroah-Hartman
parent 9040ecb593
commit 6b2175ccec

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/ctype.h>
#include <linux/string.h>
#include "spk_types.h"
#include "spk_priv.h"
#include "speakup.h"
@ -265,10 +266,10 @@ int spk_set_string_var(const char *page, struct st_var_header *var, int len)
if (!var->p_val)
var->p_val = var_data->u.s.default_val;
if (var->p_val != var_data->u.s.default_val)
strcpy((char *)var->p_val, var_data->u.s.default_val);
strscpy((char *)var->p_val, var_data->u.s.default_val, MAXVARLEN + 1);
return -ERESTART;
} else if (var->p_val) {
strcpy((char *)var->p_val, page);
strscpy((char *)var->p_val, page, MAXVARLEN + 1);
} else {
return -E2BIG;
}