From nobody Mon Oct 18 11:18:16 2021 X-Original-To: dev-commits-src-branches@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 C74081805913; Mon, 18 Oct 2021 11:18:16 +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 4HXvWD56pGz3QsR; Mon, 18 Oct 2021 11:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8EBA11F741; Mon, 18 Oct 2021 11:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19IBIGJF039707; Mon, 18 Oct 2021 11:18:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19IBIGPX039706; Mon, 18 Oct 2021 11:18:16 GMT (envelope-from git) Date: Mon, 18 Oct 2021 11:18:16 GMT Message-Id: <202110181118.19IBIGPX039706@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Yoshihiro Takahashi Subject: git: 94c3735b74f7 - stable/12 - unzip: Fix segmentation fault if a zip file contains buggy filename. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: nyan X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 94c3735b74f796a8b271091a8ebc276021345d79 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by nyan: URL: https://cgit.FreeBSD.org/src/commit/?id=94c3735b74f796a8b271091a8ebc276021345d79 commit 94c3735b74f796a8b271091a8ebc276021345d79 Author: Yoshihiro Takahashi AuthorDate: 2021-10-10 11:49:19 +0000 Commit: Yoshihiro Takahashi CommitDate: 2021-10-18 11:17:27 +0000 unzip: Fix segmentation fault if a zip file contains buggy filename. PR: 259011 Reported by: Robert Morris Submitted by: ak (cherry picked from commit 2c614481fd5248c1685e713f67d40cf2d5fba494) --- usr.bin/unzip/unzip.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c index e5ca1ff2c939..0b564b0f08ec 100644 --- a/usr.bin/unzip/unzip.c +++ b/usr.bin/unzip/unzip.c @@ -211,6 +211,9 @@ pathdup(const char *path) char *str; size_t i, len; + if (path == NULL || path[0] == '\0') + return (NULL); + len = strlen(path); while (len && path[len - 1] == '/') len--; @@ -697,7 +700,11 @@ extract(struct archive *a, struct archive_entry *e) mode_t filetype; char *p, *q; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* sanity checks */ @@ -760,7 +767,11 @@ extract_stdout(struct archive *a, struct archive_entry *e) char *pathname; mode_t filetype; - pathname = pathdup(archive_entry_pathname(e)); + if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) { + warningx("skipping empty or unreadable filename entry"); + ac(archive_read_data_skip(a)); + return; + } filetype = archive_entry_filetype(e); /* I don't think this can happen in a zipfile.. */