* [PATCH] accessibility: speakup: refactor deprecated strcpy
@ 2026-08-07 11:10 Ajith P V
2026-08-07 11:52 ` Samuel Thibault
0 siblings, 1 reply; 2+ messages in thread
From: Ajith P V @ 2026-08-07 11:10 UTC (permalink / raw)
To: w.d.hubbs, chris, kirk, samuel.thibault; +Cc: speakup, linux-kernel, Ajith P V
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>
---
drivers/accessibility/speakup/varhandlers.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/accessibility/speakup/varhandlers.c b/drivers/accessibility/speakup/varhandlers.c
index 462f8d879053..c6d3b4cc1af8 100644
--- a/drivers/accessibility/speakup/varhandlers.c
+++ b/drivers/accessibility/speakup/varhandlers.c
@@ -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;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] accessibility: speakup: refactor deprecated strcpy
2026-08-07 11:10 [PATCH] accessibility: speakup: refactor deprecated strcpy Ajith P V
@ 2026-08-07 11:52 ` Samuel Thibault
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Thibault @ 2026-08-07 11:52 UTC (permalink / raw)
To: Ajith P V; +Cc: w.d.hubbs, chris, kirk, speakup, linux-kernel
Ajith P V, le ven. 07 août 2026 11:10:58 +0000, a ecrit:
> 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>
> ---
> drivers/accessibility/speakup/varhandlers.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accessibility/speakup/varhandlers.c b/drivers/accessibility/speakup/varhandlers.c
> index 462f8d879053..c6d3b4cc1af8 100644
> --- a/drivers/accessibility/speakup/varhandlers.c
> +++ b/drivers/accessibility/speakup/varhandlers.c
> @@ -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;
> }
> --
> 2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-07 12:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 11:10 [PATCH] accessibility: speakup: refactor deprecated strcpy Ajith P V
2026-08-07 11:52 ` Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox