From nobody Sun Oct 10 11:50:48 2021 X-Original-To: dev-commits-src-main@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 9047317F81C6; Sun, 10 Oct 2021 11:50:48 +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 4HS0cS3hztz4XfP; Sun, 10 Oct 2021 11:50:48 +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 5F7325127; Sun, 10 Oct 2021 11:50:48 +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 19ABomCf098035; Sun, 10 Oct 2021 11:50:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19ABomdm098034; Sun, 10 Oct 2021 11:50:48 GMT (envelope-from git) Date: Sun, 10 Oct 2021 11:50:48 GMT Message-Id: <202110101150.19ABomdm098034@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Yoshihiro Takahashi Subject: git: 2c614481fd52 - main - unzip: Fix segmentation fault if a zip file contains buggy filename. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2c614481fd5248c1685e713f67d40cf2d5fba494 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by nyan: URL: https://cgit.FreeBSD.org/src/commit/?id=2c614481fd5248c1685e713f67d40cf2d5fba494 commit 2c614481fd5248c1685e713f67d40cf2d5fba494 Author: Yoshihiro Takahashi AuthorDate: 2021-10-10 11:49:19 +0000 Commit: Yoshihiro Takahashi CommitDate: 2021-10-10 11:49:19 +0000 unzip: Fix segmentation fault if a zip file contains buggy filename. PR: 259011 Reported by: Robert Morris Submitted by: ak MFC after:: 1 week --- 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.. */