From nobody Sun Oct 10 17:09:17 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 0DCAC17DD4EC; Sun, 10 Oct 2021 17:09:18 +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 4HS7gx6xwtz3KVG; Sun, 10 Oct 2021 17:09:17 +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 CE43111AA6; Sun, 10 Oct 2021 17:09:17 +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 19AH9HC0017678; Sun, 10 Oct 2021 17:09:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19AH9HLC017677; Sun, 10 Oct 2021 17:09:17 GMT (envelope-from git) Date: Sun, 10 Oct 2021 17:09:17 GMT Message-Id: <202110101709.19AH9HLC017677@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 852336780877 - stable/13 - kern_ctf: Use zlib's uncompress function for simpler code. 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: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 85233678087751084de3e67117ac906c3a39418d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=85233678087751084de3e67117ac906c3a39418d commit 85233678087751084de3e67117ac906c3a39418d Author: Yoshihiro Ota AuthorDate: 2021-09-26 06:28:43 +0000 Commit: Xin LI CommitDate: 2021-10-10 17:08:53 +0000 kern_ctf: Use zlib's uncompress function for simpler code. Reviewed by: markj, delphij MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D21531 --- sys/kern/kern_ctf.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c index 6a6a08033137..ee7576ab6fb9 100644 --- a/sys/kern/kern_ctf.c +++ b/sys/kern/kern_ctf.c @@ -244,7 +244,7 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) /* Check if decompression is required. */ if (raw != NULL) { - z_stream zs; + uLongf destlen; int ret; /* @@ -253,22 +253,12 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc) */ bcopy(ctf_hdr, ctftab, sizeof(ctf_hdr)); - /* Initialise the zlib structure. */ - bzero(&zs, sizeof(zs)); - - if (inflateInit(&zs) != Z_OK) { - error = EIO; - goto out; - } - - zs.avail_in = shdr[i].sh_size - sizeof(ctf_hdr); - zs.next_in = ((uint8_t *) raw) + sizeof(ctf_hdr); - zs.avail_out = sz - sizeof(ctf_hdr); - zs.next_out = ((uint8_t *) ctftab) + sizeof(ctf_hdr); - ret = inflate(&zs, Z_FINISH); - inflateEnd(&zs); - if (ret != Z_STREAM_END) { - printf("%s(%d): zlib inflate returned %d\n", __func__, __LINE__, ret); + destlen = sz - sizeof(ctf_hdr); + ret = uncompress(((uint8_t *) ctftab) + sizeof(ctf_hdr), + &destlen, ((uint8_t *) raw) + sizeof(ctf_hdr), + shdr[i].sh_size - sizeof(ctf_hdr)); + if (ret != Z_OK) { + printf("%s(%d): zlib uncompress returned %d\n", __func__, __LINE__, ret); error = EIO; goto out; }