bsdinstall(8): Sprinkle a snprintf to fixed size buffer

Use a snprintf to write an environment variable to a fixed-size buffer to
avoid stack overflow.

Reported by:	Coverity (CWE-120)
CID:		1238926
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2017-04-14 00:36:45 +00:00
parent bcbaf9fd47
commit 6c546e77b6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316802

View File

@ -146,7 +146,7 @@ newfs_command(const char *fstype, char *command, int use_default)
strcpy(command, "zpool create -f -m none ");
if (getenv("BSDINSTALL_TMPBOOT") != NULL) {
char zfsboot_path[MAXPATHLEN];
sprintf(zfsboot_path, "%s/zfs",
snprintf(zfsboot_path, sizeof(zfsboot_path), "%s/zfs",
getenv("BSDINSTALL_TMPBOOT"));
mkdir(zfsboot_path, S_IRWXU | S_IRGRP | S_IXGRP |
S_IROTH | S_IXOTH);