aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-06-27 17:19:32 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2023-06-27 17:19:32 +0000
commitf66a8328c3effcb4fbd7807b798d0288b865421d (patch)
tree8a81547625cfc404987363ccad7024bfdcffaf9b /usr.sbin
parentf5e73306336f22b842da143f973f08c5dcd13671 (diff)
downloadsrc-f66a8328c3effcb4fbd7807b798d0288b865421d.tar.gz
src-f66a8328c3effcb4fbd7807b798d0288b865421d.zip
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bsdinstall/partedit/scripted.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c
index 48ac94d112f2..62c36724d7c5 100644
--- a/usr.sbin/bsdinstall/partedit/scripted.c
+++ b/usr.sbin/bsdinstall/partedit/scripted.c
@@ -195,23 +195,26 @@ int parse_disk_config(char *input)
int
scripted_editor(int argc, const char **argv)
{
- char *token;
- int i, error = 0, len = 0;
+ FILE *fp;
+ char *input, *token;
+ size_t len;
+ int i, error = 0;
- for (i = 1; i < argc; i++)
- len += strlen(argv[i]) + 1;
- char inputbuf[len], *input = inputbuf;
- strcpy(input, argv[1]);
+ fp = open_memstream(&input, &len);
+ fputs(argv[1], fp);
for (i = 2; i < argc; i++) {
- strcat(input, " ");
- strcat(input, argv[i]);
+ fprintf(fp, " %s", argv[i]);
}
+ fclose(fp);
while ((token = strsep(&input, ";")) != NULL) {
error = parse_disk_config(token);
- if (error != 0)
+ if (error != 0) {
+ free(input);
return (error);
+ }
}
+ free(input);
return (0);
}