Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5ae11dc authored by Rickard Strandqvist's avatar Rickard Strandqvist Committed by Jiri Kosina
Browse files

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: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 429a91db
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ int set_unload_heads_path(char *device)
	if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
	if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
		return -EINVAL;
		return -EINVAL;
	strncpy(devname, device + 5, sizeof(devname));
	strncpy(devname, device + 5, sizeof(devname));
	devname[sizeof(devname) - 1] = '\0';


	snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
	snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
				"/sys/block/%s/device/unload_heads", devname);
				"/sys/block/%s/device/unload_heads", devname);