提交 d5ae11dc 编写于 作者: R Rickard Strandqvist 提交者: Jiri Kosina

doc: hpfall.c: fix missing null-terminate after strncpy call

Added a guaranteed null-terminate after call to strncpy.

This was partly found using a static code analysis program called cppcheck.
Signed-off-by: NRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 429a91db
......@@ -28,6 +28,7 @@ int set_unload_heads_path(char *device)
if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
return -EINVAL;
strncpy(devname, device + 5, sizeof(devname));
devname[sizeof(devname) - 1] = '\0';
snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
"/sys/block/%s/device/unload_heads", devname);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册