diff mbox series

[2/3] tools/thermal/tmon: Make sure ctrl_cdev is a Null terminated string

Message ID 20250509154435.14670-3-trenn@suse.de
State New
Headers show
Series tools/thermal/tmon: Fix predictable temporary path /var/log/tmon.log | expand

Commit Message

Thomas Renninger May 9, 2025, 3:44 p.m. UTC
Found by compiler warning:
warning: ‘strncpy’ specified bound 20 equals destination size [-Wstringop-truncation]

Signed-off-by: Thomas Renninger <trenn@suse.com>
---
 tools/thermal/tmon/tmon.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c
index e7392c0f6388..f803f2a2fb12 100644
--- a/tools/thermal/tmon/tmon.c
+++ b/tools/thermal/tmon/tmon.c
@@ -251,6 +251,7 @@  int main(int argc, char **argv)
 		case 'c':
 			no_control = 0;
 			strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
+			ctrl_cdev[CDEV_NAME_SIZE - 1] = 0;
 			break;
 		case 'd':
 			start_daemon_mode();