doc: hpfall.c: fix missing null-terminate after strncpy call
authorRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Wed, 4 Jun 2014 21:28:10 +0000 (23:28 +0200)
committerJiri Kosina <jkosina@suse.cz>
Thu, 19 Jun 2014 13:20:26 +0000 (15:20 +0200)
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>
Documentation/laptops/hpfall.c

index b85dbbac049933dd9dc6f6f45568f3725246f032..67084321dab4be9a4bb0189dfd00f877ea89f041 100644 (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);