Date: Fri, 5 Jan 2024 00:23:09 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: a403492f96be - stable/13 - bsdinstall partedit: Use asprintf to build wrapper command for newfs Message-ID: <202401050023.4050N9Vn025472@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a403492f96be71caa46e887bec58be5091d0c8f8 commit a403492f96be71caa46e887bec58be5091d0c8f8 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2023-10-16 23:25:25 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-01-05 00:11:11 +0000 bsdinstall partedit: Use asprintf to build wrapper command for newfs Don't abuse the message[] static buffer used elsewhere for error messages to generate the command that actually newfs's each filesystem. Use asprintf to a more aptly-named 'char *command' variable to construct the string instead. This avoids potential bugs from truncation of the command string. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42239 (cherry picked from commit a8676bf367b099dcc97ff61031cbf4ceb5e37899) --- usr.sbin/bsdinstall/partedit/partedit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c index 0f116d2c716a..c8961d03c5cc 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.c +++ b/usr.sbin/bsdinstall/partedit/partedit.c @@ -336,6 +336,7 @@ apply_changes(struct gmesh *mesh) const char **items; const char *fstab_path; FILE *fstab; + char *command; nitems = 1; /* Partition table changes */ TAILQ_FOREACH(md, &part_metadata, metadata) { @@ -374,10 +375,11 @@ apply_changes(struct gmesh *mesh) dialog_mixedgauge("Initializing", "Initializing file systems. Please wait.", 0, 0, i*100/nitems, nitems, __DECONST(char **, items)); - sprintf(message, "(echo %s; %s) >>%s 2>>%s", + asprintf(&command, "(echo %s; %s) >>%s 2>>%s", md->newfs, md->newfs, getenv("BSDINSTALL_LOG"), getenv("BSDINSTALL_LOG")); - error = system(message); + error = system(command); + free(command); items[i*2 + 1] = (error == 0) ? "3" : "1"; i++; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401050023.4050N9Vn025472>