diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c --- a/usr.sbin/bsdinstall/partedit/partedit.c +++ b/usr.sbin/bsdinstall/partedit/partedit.c @@ -428,14 +428,17 @@ free(tobesorted); } - if (getenv("PATH_FSTAB") != NULL) - fstab_path = getenv("PATH_FSTAB"); - else + fstab_path = getenv("PATH_FSTAB"); + if (fstab_path == NULL) fstab_path = "/etc/fstab"; fstab = fopen(fstab_path, "w+"); if (fstab == NULL) { - sprintf(message, "Cannot open fstab file %s for writing (%s)\n", - getenv("PATH_FSTAB"), strerror(errno)); + error = snprintf(message, sizeof(message), "Cannot open fstab file %s" + " for writing (%s)\n", fstab_path, strerror(errno)); + if (error < 0) { + snprintf(message, sizeof(message), "Cannot open fstab file for" + " writing (%s)\n", strerror(errno)); + } conf.title = "Error"; bsddialog_msgbox(&conf, message, 0, 0); return (-1);