From nobody Fri Jan 05 00:23:04 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T5kgr5Y92z55fJ5; Fri, 5 Jan 2024 00:23:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T5kgr3g99z4dSw; Fri, 5 Jan 2024 00:23:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704414184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=07avkOBc3SgKoshmH582t8Czy1HIbDUDZgQu+nxQzFM=; b=U8JHRTJTK+R5ytBn1/tadEXagOZ5jnjM/orAn4kOsym70fMzFBTui8p391JMXhx470PElU qqT82mxI3zRoJ1E/l4rKDYFN/65UhSWTrJFEP+7X4TI5PD77VnOqJlW/upR2oyyrJ2ZPND Cy41mc8I/8GN1pz1tLQgbO3S0hNDrptAxu0CPZIUxoyBcCdaiwzTjZP/idFtDR9xafDIGi RB0QlocYQNlxJBYrzIkdljFuLtmISlhwnQrHHEhYhtI6VI3knEWDtVpmGi5lIT/s3tpR5C MhR8ABNRO1WCidCPskdHV5G/C3zzL2AXW1iAgM1px/QsPeBqese4rbUMG9Qjfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704414184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=07avkOBc3SgKoshmH582t8Czy1HIbDUDZgQu+nxQzFM=; b=Qs4JAJvoXj7I154m9UxaoXF3qPKvPIxj5tWoPGk4tIfgq8/S3wji9mTTyVxw0l75ZjpCJk FXEm62NNheSUsp+D60LsGCpsKBLgt2gMYHIZsF0ji2WBedDzfHkkIMpbG4jGvrSOj9pkjp Bt9QaKmPWh2XbqeEpRVYHg4whPFzJ+RcHA7B/xbSh9VeYjDUSlNwNv6sILtO62113lvAbN 8Khu+3XVL86tPf+GcEZLb+/Bl99XGMV5XtSZukCipZgj/SLE+/lgaWlqkIq0evZJ7WyP5B JXQ1MnLTHiZPIN87nw36PG7Uw4O14ny8AKheNAWB/YjM63WIzp4Xnh4QALjpsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704414184; a=rsa-sha256; cv=none; b=qqhpvz9lVIxolKLZQNPOiR1chAKBD8q6MucetDbyooOtRPoDS0ocUParwhjwUzS6hiuZow phlwcJCakVk6YMP0rddSK0t7c4PAZU1+bNxTI5nozkWbVb6HQtxhBW8EOU0Ky6tmsBlUjH +/6mXk9bZA8WzE6o3IQhS8Q7VsaoLFf/dcSQ4GTqpYVqR0feA870eXgfgp85UD6F9IQeJE NSB5RNoJrOJRIxCZRjVtCNB4lM3TQmkh36sYwiaIHHQs2LufYm5rDRTbKYOk+ILBQgKGWr +ys+xW/Ex/RoNrFU+Pd9qg4RAacl7psApJEDXleTMGmudIN0Rb4c/hBhq5xxrw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T5kgr2ltBzZn1; Fri, 5 Jan 2024 00:23:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4050N4uQ025214; Fri, 5 Jan 2024 00:23:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4050N42W025210; Fri, 5 Jan 2024 00:23:04 GMT (envelope-from git) Date: Fri, 5 Jan 2024 00:23:04 GMT Message-Id: <202401050023.4050N42W025210@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 3c9405052568 - stable/13 - bsdinstall: Replace correct, but fragile, string builder with open_memstream. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3c9405052568fcc33ed815b0913aab432b2cb912 Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3c9405052568fcc33ed815b0913aab432b2cb912 commit 3c9405052568fcc33ed815b0913aab432b2cb912 Author: John Baldwin AuthorDate: 2023-06-27 17:19:32 +0000 Commit: John Baldwin CommitDate: 2024-01-04 23:16:48 +0000 bsdinstall: Replace correct, but fragile, string builder with open_memstream. The old one triggered a false positive -Warray-bounds from GCC (the compiler assumed len was always 0), but it was also fragile with manually computed lengths paired with strcat vs using a string builder. Differential Revision: https://reviews.freebsd.org/D40658 (cherry picked from commit f66a8328c3effcb4fbd7807b798d0288b865421d) --- usr.sbin/bsdinstall/partedit/scripted.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bsdinstall/partedit/scripted.c b/usr.sbin/bsdinstall/partedit/scripted.c index 08cabf4e0989..69fba8f2cfa8 100644 --- a/usr.sbin/bsdinstall/partedit/scripted.c +++ b/usr.sbin/bsdinstall/partedit/scripted.c @@ -194,23 +194,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); }