char: ipmi: Replace deprecated strcpy with strscpy
PATCH 1/1 char: ipmi: Replace deprecated strcpy with strscpy
strcpy() has been deprecated because it is generally unsafe and can lead to buffer overflows. It is actively being removed from the kernel.
In action_op() and preop_op() (and related functions), strings are copied into fixed-size buffers. Replace the strcpy() calls with strscpy() using the sizeof() the destination buffers to guarantee NUL-termination and prevent any potential bounds issues, ensuring compliance with safe string APIs.
--- drivers/char/ipmi/ipmi_watchdog.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/char/ipmi/ipmi_watchdog.c +6 -6
@@ -1166,13 +1166,13 @@ static int action_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, action); +strscpy (outval, action,sizeof (action));if (!inval)return 0 ; rv =action_op_set_val (inval);if (!rv) -strcpy (action, inval); +strscpy (action, inval,sizeof (action));return rv; }
@@ -1198,13 +1198,13 @@ static int preaction_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, preaction); +strscpy (outval, preaction,sizeof (preaction));if (!inval)return 0 ; rv =preaction_op_set_val (inval);if (!rv) -strcpy (preaction, inval); +strscpy (preaction, inval,sizeof (preaction));return 0 ; }
@@ -1226,14 +1226,14 @@ static int preop_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, preop); +strscpy (outval, preop,sizeof (preop));if (!inval)return 0 ; rv =preop_op_set_val (inval);if (!rv) -strcpy (preop, inval); +strscpy (preop, inval,sizeof (preop));return 0 ; }
Signature · 1 line
2.43.0
Quoted 8 lines · Ashutosh Yadav
strcpy()has been deprecated because it is generally unsafe and can lead to buffer overflows. It is actively being removed from the kernel.In
action_op()andpreop_op()(and related functions), strings are copied into fixed-size buffers. Replace thestrcpy()calls withstrscpy()using thesizeof()the destination buffers to guarantee NUL-termination and prevent any potential bounds issues, ensuring compliance with safe string APIs.
Applied, thank you.
-corey
Quoted 63 lines
Signed-off-by Ashutosh Yadav <[email protected]>--- drivers/char/ipmi/ipmi_watchdog.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/char/ipmi/ipmi_watchdog.c +6
-6@@ -1166,13 +1166,13 @@ static int action_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, action); +strscpy (outval, action,sizeof (action));if (!inval)return 0 ; rv =action_op_set_val (inval);if (!rv) -strcpy (action, inval); +strscpy (action, inval,sizeof (action));return rv; }@@ -1198,13 +1198,13 @@ static int preaction_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, preaction); +strscpy (outval, preaction,sizeof (preaction));if (!inval)return 0 ; rv =preaction_op_set_val (inval);if (!rv) -strcpy (preaction, inval); +strscpy (preaction, inval,sizeof (preaction));return 0 ; }@@ -1226,14 +1226,14 @@ static int preop_op(const char *inval, char *outval)int rv;if (outval) -strcpy (outval, preop); +strscpy (outval, preop,sizeof (preop));if (!inval)return 0 ; rv =preop_op_set_val (inval);if (!rv) -strcpy (preop, inval); +strscpy (preop, inval,sizeof (preop));return 0 ; }Signature · 1 line
2.43.0