From 6c546e77b64a90b5ae6d9c7fdd4bdf4059aaf296 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Fri, 14 Apr 2017 00:36:45 +0000 Subject: [PATCH] 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 --- usr.sbin/bsdinstall/partedit/gpart_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 26f8f46703d4..9720b3363cd0 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -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);