Skip to content

Commit

Permalink
ipmi: use correct string length
Browse files Browse the repository at this point in the history
gcc-8 reports

drivers/char/ipmi/ipmi_msghandler.c: In function
'panic_op_write_handler':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 16 equals destination size [-Wstringop-truncation]

drivers/char/ipmi/ipmi_watchdog.c: In function 'set_param_str':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 16 equals destination size [-Wstringop-truncation]

We need one less byte or call strlcpy() to make it a nul-terminated
string.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
  • Loading branch information
Xiongfeng Wang authored and Corey Minyard committed Jan 9, 2018
1 parent 174134a commit 1b4254c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_msghandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int panic_op_write_handler(const char *val,
char valcp[16];
char *s;

strncpy(valcp, val, 16);
strncpy(valcp, val, 15);
valcp[15] = '\0';

s = strstrip(valcp);
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmi_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int set_param_str(const char *val, const struct kernel_param *kp)
char valcp[16];
char *s;

strncpy(valcp, val, 16);
strncpy(valcp, val, 15);
valcp[15] = '\0';

s = strstrip(valcp);
Expand Down

0 comments on commit 1b4254c

Please sign in to comment.