提交 6e641c94 编写于 作者: S Stefan Weil 提交者: Jiri Kosina

Documentation: Fix size parameter for snprintf

cppcheck reports this error:

Documentation/laptops/hpfall.c:33]: (error)
 Dangerous usage of 'devname' (strncpy doesn't always 0-terminate it)

The terminating '\0' is needed for the global char array unload_heads_path,
so never write the last array entry (which is initially '\0').
Signed-off-by: NStefan Weil <sw@weilnetz.de>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 e0ea0414
......@@ -29,7 +29,7 @@ int set_unload_heads_path(char *device)
return -EINVAL;
strncpy(devname, device + 5, sizeof(devname));
snprintf(unload_heads_path, sizeof(unload_heads_path),
snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
"/sys/block/%s/device/unload_heads", devname);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册