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: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
Rickard Strandqvist 2014-06-04 23:28:10 +02:00 committed by Jiri Kosina
parent 429a91db3b
commit d5ae11dc40
1 changed files with 1 additions and 0 deletions

View File

@ -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);