Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rickard Strandqvist and committed by
Jiri Kosina
d5ae11dc 429a91db

+1
+1
Documentation/laptops/hpfall.c
··· 28 28 if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0) 29 29 return -EINVAL; 30 30 strncpy(devname, device + 5, sizeof(devname)); 31 + devname[sizeof(devname) - 1] = '\0'; 31 32 32 33 snprintf(unload_heads_path, sizeof(unload_heads_path) - 1, 33 34 "/sys/block/%s/device/unload_heads", devname);