From nobody Sat May 4 12:37:37 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 4VWnJ206qyz5KVVS; Sat, 4 May 2024 12:37:38 +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 4VWnJ13cg1z44Xl; Sat, 4 May 2024 12:37:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714826257; 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=ZSPiU1AdlgJ1v993/d2X2M7aGCLn0MGZsSQTCtK1iqM=; b=e0UuZpaDCKG0JedJBTFTa3jOi0KC3wl2WQ7p2m0v9mbfzNMdmAbmHkn1J+5NULT198FNNZ OAJGCoWxY7cWbXAw5SMwl3nv4rlhYFTI3LLUxhwPtRkyjdkBD3dUSgQcTpFP/pKg93Vmtv j01FO3fxg1ojkj4hkB792XuMi6Y70OQU4k1MB3XwX/m1Vip934n7qEmvhNucKT3k7PN1QS EEA4N4ejbGc5GucwwicvnO8lhtRWRVq600UWz+rm7BXjRxPA4M9GcGwEbnf4yuH5LDK0XH bq3NmqQMvmrGWuYWig3sZmTxdjJphdS4nR7bZY+K68Z0d+7hCtb+KOwPvOV2tQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714826257; a=rsa-sha256; cv=none; b=wcQt12PIyuVdqbrE74FTwYEBoFZ2jl6jb71qbYmkKj9zfBIKWoFT4wCooOvhU1QSsLLIwL VAC/mMQCJJFYjnR2T8uuE+7Ct3d6M62bgrjqR18LhoaKRuvXQ+hUHBA2rJSkYAkH+Z+xwW WGliT6G727iRRU0LbBnJ7ZP4VrixWVvGny8Hv4dw/ep0UkTU+6QY8OCMAG/6lZVdA/IKtQ YYs1Kszn0cgJZdYyPk4WCNAcjl62jTpVKUExBBYD7l38Sgaqe82KaWhQe9x4ba7k1tqs06 ghCW1M8Qry0VakYYchMJwm7UHkazUX7IwIplXhiMsbPteVngYCqXXe7yiNH+BQ== 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=1714826257; 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=ZSPiU1AdlgJ1v993/d2X2M7aGCLn0MGZsSQTCtK1iqM=; b=FPffzQgr8U6PmTCInPjd0ih9sBYfnAbJxbeEvfWeTFpg42gkBuBNBLTaBPR99ozZTT1edp cUYKE/DkivTHvSO9AQh1vOK04fOUuD1bHTDl64jjS2st4JaMW9zJACw+efWsxjTw7plXT5 GaBgyrz2xn4RBLBMvRnL4GvJrBuDct1mjqwquKM2lx0fislZH0sCrkH2tL05Kk/gICmcRe 8jNMwy1g/p6zRT9GcbaIOHkKg1hXE/yfXmYkXg5QUvaChhAVwrdTca03dBOrieZaZ2B4Q9 3zKLOIsrkzumHxliYJtTewTVUCs4pGjQfr4XCKP3qKo/Fzm00U8t7iOZ9sECrA== 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 4VWnJ139lNzVxj; Sat, 4 May 2024 12:37:37 +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 444CbbNq072414; Sat, 4 May 2024 12:37:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 444CbbPi072411; Sat, 4 May 2024 12:37:37 GMT (envelope-from git) Date: Sat, 4 May 2024 12:37:37 GMT Message-Id: <202405041237.444CbbPi072411@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Martin Matuska Subject: git: db2cc817faf9 - stable/13 - libarchive: merge from vendor branch 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: db2cc817faf924bd898046547dde984162f806ec Auto-Submitted: auto-generated The branch stable/13 has been updated by mm: URL: https://cgit.FreeBSD.org/src/commit/?id=db2cc817faf924bd898046547dde984162f806ec commit db2cc817faf924bd898046547dde984162f806ec Author: Martin Matuska AuthorDate: 2023-08-03 23:04:14 +0000 Commit: Martin Matuska CommitDate: 2024-05-04 11:53:07 +0000 libarchive: merge from vendor branch Changes to not yet connected unzip only. (cherry picked from commit 058ab969fd2f7a8d04240d1e9bc9d63918480226) --- contrib/libarchive/unzip/bsdunzip.c | 19 ++++++++++++++++ contrib/libarchive/unzip/bsdunzip.h | 7 ++---- contrib/libarchive/unzip/cmdline.c | 2 -- contrib/libarchive/unzip/test/test_d.c | 22 +++++++++++++++++-- contrib/libarchive/unzip/test/test_x.c | 40 ++++++++++++++++++++++++++++++++-- 5 files changed, 79 insertions(+), 11 deletions(-) diff --git a/contrib/libarchive/unzip/bsdunzip.c b/contrib/libarchive/unzip/bsdunzip.c index b8f6ff4bbf95..29c3a1670483 100644 --- a/contrib/libarchive/unzip/bsdunzip.c +++ b/contrib/libarchive/unzip/bsdunzip.c @@ -113,6 +113,9 @@ static int zipinfo_mode; /* running on tty? */ static int tty; +/* processing exclude list */ +static int unzip_exclude_mode = 0; + int bsdunzip_optind; /* convenience macro */ @@ -1114,6 +1117,7 @@ getopts(int argc, char *argv[]) bsdunzip->argc = argc; while ((opt = bsdunzip_getopt(bsdunzip)) != -1) { + unzip_exclude_mode = 0; switch (opt) { case 'a': a_opt = 1; @@ -1171,6 +1175,7 @@ getopts(int argc, char *argv[]) break; case 'x': add_pattern(&exclude, bsdunzip->argument); + unzip_exclude_mode = 1; break; case 'y': y_str = " "; @@ -1245,12 +1250,26 @@ main(int argc, char *argv[]) if (strcmp(zipfile, "-") == 0) zipfile = NULL; /* STDIN */ + unzip_exclude_mode = 0; + while (nopts < argc && *argv[nopts] != '-') add_pattern(&include, argv[nopts++]); nopts--; /* fake argv[0] */ nopts += getopts(argc - nopts, argv + nopts); + /* + * For compatibility with Info-ZIP's unzip(1) we need to treat + * non-option arguments following an -x after the zipfile as + * exclude list members. + */ + if (unzip_exclude_mode) { + while (nopts < argc && *argv[nopts] != '-') + add_pattern(&exclude, argv[nopts++]); + nopts--; /* fake argv[0] */ + nopts += getopts(argc - nopts, argv + nopts); + } + /* There may be residual arguments if we encountered -- */ while (nopts < argc) add_pattern(&include, argv[nopts++]); diff --git a/contrib/libarchive/unzip/bsdunzip.h b/contrib/libarchive/unzip/bsdunzip.h index 12b65cefb466..ab81e3930ec2 100644 --- a/contrib/libarchive/unzip/bsdunzip.h +++ b/contrib/libarchive/unzip/bsdunzip.h @@ -48,11 +48,6 @@ struct bsdunzip { const char *argument; }; -struct bsdunzip_getopt_ret { - int index; - int opt; -}; - enum { OPTION_NONE, OPTION_VERSION @@ -60,4 +55,6 @@ enum { int bsdunzip_getopt(struct bsdunzip *); +extern int bsdunzip_optind; + #endif diff --git a/contrib/libarchive/unzip/cmdline.c b/contrib/libarchive/unzip/cmdline.c index 95d4f99b8242..76eb423de116 100644 --- a/contrib/libarchive/unzip/cmdline.c +++ b/contrib/libarchive/unzip/cmdline.c @@ -43,8 +43,6 @@ __FBSDID("$FreeBSD$"); #include "bsdunzip.h" #include "err.h" -extern int bsdunzip_optind; - /* * Short options for bsdunzip. Please keep this sorted. */ diff --git a/contrib/libarchive/unzip/test/test_d.c b/contrib/libarchive/unzip/test/test_d.c index 64950cbbe165..01ab9b8caaa3 100644 --- a/contrib/libarchive/unzip/test/test_d.c +++ b/contrib/libarchive/unzip/test/test_d.c @@ -25,8 +25,8 @@ */ #include "test.h" -/* Test d arg - extract to target dir */ -DEFINE_TEST(test_d) +/* Test d arg - extract to target dir - before zipfile argument */ +DEFINE_TEST(test_d_before_zipfile) { const char *reffile = "test_basic.zip"; int r; @@ -42,3 +42,21 @@ DEFINE_TEST(test_d) assertTextFileContents("contents c\n", "foobar/test_basic/c"); assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS"); } + +/* Test d arg - extract to target dir - after zipfile argument */ +DEFINE_TEST(test_d_after_zipfile) +{ + const char *reffile = "test_basic.zip"; + int r; + + extract_reference_file(reffile); + r = systemf("%s %s -d foobar >test.out 2>test.err", testprog, reffile); + assertEqualInt(0, r); + assertNonEmptyFile("test.out"); + assertEmptyFile("test.err"); + + assertTextFileContents("contents a\n", "foobar/test_basic/a"); + assertTextFileContents("contents b\n", "foobar/test_basic/b"); + assertTextFileContents("contents c\n", "foobar/test_basic/c"); + assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS"); +} diff --git a/contrib/libarchive/unzip/test/test_x.c b/contrib/libarchive/unzip/test/test_x.c index 21f01bf65da8..d55376849ce9 100644 --- a/contrib/libarchive/unzip/test/test_x.c +++ b/contrib/libarchive/unzip/test/test_x.c @@ -25,8 +25,8 @@ */ #include "test.h" -/* Test x arg - Exclude paths */ -DEFINE_TEST(test_x) +/* Test x arg with single exclude path */ +DEFINE_TEST(test_x_single) { const char *reffile = "test_basic.zip"; int r; @@ -42,3 +42,39 @@ DEFINE_TEST(test_x) assertFileNotExists("test_basic/c"); assertTextFileContents("contents CAPS\n", "test_basic/CAPS"); } + +/* Test x arg with multiple exclude paths */ +DEFINE_TEST(test_x_multiple) +{ + const char *reffile = "test_basic.zip"; + int r; + + extract_reference_file(reffile); + r = systemf("%s %s -x test_basic/c test_basic/b >test.out 2>test.err", testprog, reffile); + assertEqualInt(0, r); + assertNonEmptyFile("test.out"); + assertEmptyFile("test.err"); + + assertTextFileContents("contents a\n", "test_basic/a"); + assertFileNotExists("test_basic/b"); + assertFileNotExists("test_basic/c"); + assertTextFileContents("contents CAPS\n", "test_basic/CAPS"); +} + +/* Test x arg with multiple exclude paths and a d arg afterwards */ +DEFINE_TEST(test_x_multiple_with_d) +{ + const char *reffile = "test_basic.zip"; + int r; + + extract_reference_file(reffile); + r = systemf("%s %s -x test_basic/c test_basic/b -d foobar >test.out 2>test.err", testprog, reffile); + assertEqualInt(0, r); + assertNonEmptyFile("test.out"); + assertEmptyFile("test.err"); + + assertTextFileContents("contents a\n", "foobar/test_basic/a"); + assertFileNotExists("foobar/test_basic/b"); + assertFileNotExists("foobar/test_basic/c"); + assertTextFileContents("contents CAPS\n", "foobar/test_basic/CAPS"); +}