From nobody Thu Apr 04 11:39:05 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 4V9KQL0jSlz5GrMZ; Thu, 4 Apr 2024 11:39:06 +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 4V9KQK6dHjz57lj; Thu, 4 Apr 2024 11:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712230745; 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=18+mQ2llkB9U3sbXDOmMFyUyTatKEvGiAidOgz4eLe4=; b=oJz+S54ViWEx4pUX85MS2pktMbd5MgkIoZxUznkFlwI2XnIOAa4N3Xdn8WTsqFWkSmVNbC e0rdxj7KkDAooApn4AGaRrneV0Azpe/WDk1ag/lLYI9sG77t1OmP411a/ZL9U8+SlvZjMs 28NKkRumhwjChdAp5uIpz0KigxXMRI7tuzldHoidmr6x/8bVBJ9iFLVI4y+e9IZcw/Rd4f 0cq+85k7sKT+QUQIXyoDCcwDwfq8HMuo4vLTT9C7wiVqr2CwaZV0vUAdt+KVv1kljBWdf1 yJ9a8ynyBwjoY/VrRpzWfc+CQloZoag1Dg8QY0D23WOg7Wili/TnMKsuT3/a/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712230745; a=rsa-sha256; cv=none; b=vSMgdMB7de6NMq1BMKcVzZmbUeTOFXeYE2wDC2lePSN+Swo3YcdhAyz58/YxYbSmweL0oy ODcnZfvp6CuD8K27l6qMo0e0DXR2EErE71KcapIV825WBEHCuLbICGAEgGPeh3pYHWRhZU EwP1gdtCqejXOzh5R45sH0TVOJc+1YcmYvnLuZZudTnsomemB+Gk+FlJTbxQBLIs9daY1h bHn+WFnzldAoxROqFpNNgcJ6jhW77pF6N3JmkVe8jE7MxJGv+3Tf1miWnLg7lQrEyJKI/1 rK9UOKf80Ean6wpDMrsmraJV1aydqnO1yEhtaBYWUw+7c8ygvJ0KOQyN/49U/Q== 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=1712230745; 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=18+mQ2llkB9U3sbXDOmMFyUyTatKEvGiAidOgz4eLe4=; b=V/RuffGqZTxLU7XrXofzZmAF8kHQGwL18t6IukaYgkTdL9EKH4ZMeS30OlZ7trUBfKVZ9D 3BBQMsG06oXvjOrmFDM0bW1wiQjed/6yqRiEPfkckiDxQ1x08Uid7G3o3dLnetha80Jg5E unX2kZGInNRZSST5r6sJGOYZ3ls8gdb5QLeu3ckgpw15WOC4r0BgxAmPn/RnS2yYHByLwZ eYIJKmHKDJ1OOK0u00jwzNkUj03uRu9C/NnmKFqFMKn/761F53R1oxjhPPLDSpzy/7UpTq pILd+oqGF/xwukcMgL8nEYpcJIbJVI45xtA4mG6l5LqwwitrIpu9jmiC5JFnqw== 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 4V9KQK5z9jzFgC; Thu, 4 Apr 2024 11:39:05 +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 434Bd5NM060247; Thu, 4 Apr 2024 11:39:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 434Bd5ew060244; Thu, 4 Apr 2024 11:39:05 GMT (envelope-from git) Date: Thu, 4 Apr 2024 11:39:05 GMT Message-Id: <202404041139.434Bd5ew060244@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: 8934e4a17e94 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 8934e4a17e945fbd37b4e97fc42f83d000b74d9a Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=8934e4a17e945fbd37b4e97fc42f83d000b74d9a commit 8934e4a17e945fbd37b4e97fc42f83d000b74d9a Author: Dag-Erling Smørgrav AuthorDate: 2024-03-27 10:03:59 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-04 09:51:06 +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 3bcc44d08b81..f1fe1a969377 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1507,15 +1507,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; } @@ -1540,7 +1543,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); @@ -1550,14 +1553,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)