Browse Source

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>
Rickard Strandqvist 11 years ago
parent
commit
d5ae11dc40
1 changed files with 1 additions and 0 deletions
  1. 1 0
      Documentation/laptops/hpfall.c

+ 1 - 0
Documentation/laptops/hpfall.c

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