From nobody Thu Apr 04 11:38:50 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 4V9KQ30lxXz5GrPp; Thu, 4 Apr 2024 11:38:51 +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 4V9KQ26PMrz57Qq; Thu, 4 Apr 2024 11:38:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712230730; 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=Fet3Kz+vnUYmNqMkapqaGJnDj+T9NYmPT6o13NBbt/M=; b=snwUuHkZn3HbjSTPjj449YyZzwOeUmHflBYFrX7dofDo2GEXHNUD2sUHOxU38if6x31p6B nggQxCQyOWp6A642jC6TMtMUPdOhb8qwDD1GHoMeTnvnsVkcfPEpP32sWvxYiFOBlJBV30 PqZMKaqMzk0fRb/Ita4p+LGeTEvZV+BaI7Aze1tnclWCx29xB5oSSkaiNKBYD29aEdx0uV FbLzzBLWRFggxhvBdAUPS14AyoTvaEPeBb5vBoBb4Rp8DZe/FkstPzrp6jb2VOWx2g2bgO yNTjTsrnm9xpAQfe2JwK7z64Z+DrWDy/mPz+Zgjzn0SjpNf/W2Nk8Lg4WOHJ1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712230730; a=rsa-sha256; cv=none; b=sAaI8BnOdCyN5SQRUTP4LYGPLKbgREGbOwmnn46R8ygUPX0QGicOUS1CQsy+qJYAjAyi7R ePSudHyngOvfXgZz9jjuzomTilkgAzBoPmjc72MGK+Wr0FuekeHwl+RvPTlKeK7WOImnn2 p3xxM2Gvw6XT+/G0UrvERoA5+tf3LqsGSmMmS7M4jkSQIyC1uk35VQ5uovF5Te6yZEAhLq 41HL82sLY43xdw7jNzNPJinq3BYhMKxqxOyAAjDEwicBVCgVmPAHSljjkYNrcHGgGXu5rJ tzC8YXfNLGllnULkxR6Hyqgm5Kwag/8C7h9eiN3FEuD4pJEmDUZPh4ZUIVO4FQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712230730; 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=Fet3Kz+vnUYmNqMkapqaGJnDj+T9NYmPT6o13NBbt/M=; b=ok3KKvdXsu6rD+IlwbVfbe62Tk8ch6sJAkngzkcmVWkIKCSFkW5DmKEsB1HVdIQyFkhTHT ZfiYvC2+N56Wu0qxh8jYzC0Pyo1qyAtLacTVoIrPKsgkgSQbqbt/tyjpVhmJdy2xIWSWJp DMBEEiWuAA5R81K53auj+BlvdEhRpEM6uWO8tR5fS5gn5L+eSq0OUERRWVydCNR2ykYrtN I2JqL2JP87JWbr+wVu5cUQZN5/I48YpXqRVS0tGi9b4+EDa0wM/UPsq5d9tA0rZFZWlBb0 Um4fqGekDZGXHM49FXaR0spz4C6q6N2U7egQsNhF5RCQB83AmCEiRmxOrMK+Nw== 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 4V9KQ2604JzFJL; Thu, 4 Apr 2024 11:38:50 +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 434BcoL8059795; Thu, 4 Apr 2024 11:38:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 434BcorS059791; Thu, 4 Apr 2024 11:38:50 GMT (envelope-from git) Date: Thu, 4 Apr 2024 11:38:50 GMT Message-Id: <202404041138.434BcorS059791@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 80f2602e48eb - stable/14 - install: Prefer strsnvis() to strsvis(). 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 80f2602e48ebafcc5b82909724f970d2103185c4 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=80f2602e48ebafcc5b82909724f970d2103185c4 commit 80f2602e48ebafcc5b82909724f970d2103185c4 Author: Dag-Erling Smørgrav AuthorDate: 2024-03-27 10:03:59 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-04 09:43:15 +0000 install: Prefer strsnvis() to strsvis(). MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44514 (cherry picked from commit 2cab4be46b0eeb64b8ade010bc16245151af5ccd) --- usr.bin/xinstall/xinstall.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 1ab9cac76f2f..3764c5ef92fa 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1542,15 +1542,18 @@ metadata_log(const char *path, const char *type, struct timespec *ts, static const char extra[] = { ' ', '\t', '\n', '\\', '#', '\0' }; const char *p; char *buf; - size_t destlen; + size_t buflen, destlen; struct flock metalog_lock; if (!metafp) return; - /* Buffer for strsvis(3). */ - buf = (char *)malloc(4 * strlen(path) + 1); - if (buf == NULL) { - warnx("%s", strerror(ENOMEM)); + /* Buffer for strsnvis(3), used for both path and slink. */ + buflen = strlen(path); + if (slink && strlen(slink) > buflen) + buflen = strlen(slink); + buflen = 4 * buflen + 1; + if ((buf = malloc(buflen)) == NULL) { + warn(NULL); return; } @@ -1575,7 +1578,7 @@ metadata_log(const char *path, const char *type, struct timespec *ts, } while (*p && *p == '/') p++; - strsvis(buf, p, VIS_OCTAL, extra); + strsnvis(buf, buflen, p, VIS_OCTAL, extra); p = buf; /* Print details. */ fprintf(metafp, ".%s%s type=%s", *p ? "/" : "", p, type); @@ -1585,14 +1588,14 @@ metadata_log(const char *path, const char *type, struct timespec *ts, fprintf(metafp, " gname=%s", group); fprintf(metafp, " mode=%#o", mode); if (slink) { - strsvis(buf, slink, VIS_CSTYLE, extra); /* encode link */ + strsnvis(buf, buflen, slink, VIS_CSTYLE, extra); fprintf(metafp, " link=%s", buf); } if (*type == 'f') /* type=file */ fprintf(metafp, " size=%lld", (long long)size); if (ts != NULL && dopreserve) fprintf(metafp, " time=%lld.%09ld", - (long long)ts[1].tv_sec, ts[1].tv_nsec); + (long long)ts[1].tv_sec, ts[1].tv_nsec); if (digestresult && digest) fprintf(metafp, " %s=%s", digest, digestresult); if (fflags)