From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283121; b=h01MJPnjyGAgNSnKPBx0O5lR9nfIfNHqzpDCsKyG3d5sl9OJCoFW9t5DWH11eYpQzj3W 7lcsmqeZ6Tv8VfXoZegglfr8aPHadD7a2EkGUe6U8ijaXEEA1aSPmALq7iNgPR1JeQMMg ZcknKFYSI5N2a+7ViWXh9kOHmd6cDHFSpg6czRjw26vOejfa6KW7bTzcHf0ww4pgI+0NV l0FtoHO13m+dp3HF+HOYa9KI8sIEG04uRWevUDYanGwvay+dIpbg3ZBrNvWWM9dwsM9+j uB29S54Z53JHvnoMVpOWnVX8DlJu5jnpH76+bZOKjNWnM4oXYmG6wrRSviBrYQHVfNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283121; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=V/Ri/SIR7paqPsCCSlVPjnU3Egb+qtcreF9anGo2eNM=; b=2yKZLsiVeQoxT8I+AXEuDI/psk9uxKVqEgVm10XJTXTfEZJNLYCg/6vZYTtMEIa5jldf sIKqlQpPXWATGsigRSgIMHgDpr47JnZANYrJQrt9brLIod3tpEo8Iw7oPqu2/z0qyNppf LdA6hnYN0L7BDtnsii3ZmkW+eiZqSHHRbF1prhKGglEXpw/UsVh3/51/4tXmMDtJkTBRZ WydBw26kxXct/aSWA951mCH/1FqHqKDUYQMxCx7aoe33xK/JzJHvKHnBkpUJp87/ijgQg 9ZK6Hij/gd8PPX9F1CU73ygcsi1tpHqY1LdipdwoGIX6EyzEoLdmd5txsHyVw1HsS6Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=T4NGXtmi; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 615DC606A33D for ; Thu, 3 Dec 2026 07:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=T4NGXtmi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AD351F00923; Thu, 3 Dec 2026 07:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796283121; bh=V/Ri/SIR7paqPsCCSlVPjnU3Egb+qtcreF9anGo2eNM=; h=From:Date:Subject:References:In-Reply-To:To; b=T4NGXtmiH1SoEy6PYbzlr2YTvs0fwEFIVjssvZjW/Ha0zLKfpTjdPN2Zycm/7e9IS 0NwMJRsg8ZUdiDyKRDJz1UIgTbcqsmt4+/DxZnIlZj4oJbAjr1vXi8pqxjEL0p63tQ 7QQUmyrzEl/QWamhKI+jliA4mqHAWmgsSwNhGvs8= From: Greg Kroah-Hartman Date: Thu, 03 Dec 2026 08:29:57 +0100 Subject: [PATCH 17/21] lib/zlib: catch code up to the real zlib 1.1.3 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261203-zlib-sync-v1-17-0d4ec56f1afb@linuxfoundation.org> References: <20261203-zlib-sync-v1-0-0d4ec56f1afb@linuxfoundation.org> In-Reply-To: <20261203-zlib-sync-v1-0-0d4ec56f1afb@linuxfoundation.org> To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman X-Mailer: b4 0.17-dev-73bef X-Developer-Signature: v=1; a=openpgp-sha256; l=5730; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=4TTqXu9mPB25hhrAU4LvvdxBdR89eVanvj2aUQpXFn0=; b=owGbwMvMwCRo6H6F97bub03G02pJDNmCUtnl97tNi6u8uwSjhaqU9QOSzpyKF4jWKNl9Y+NO7 clPLwV3xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwETKChkWLN3m3eXj2f2x30h1 79wGMfnE4+vEGeZHs4b/8a9rLRVkmHA7wU3oWp/uq4UA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Despite the kernel code claiming to be newer, there are two parts of the deflate code that were older than the 1.1.3 version. Fix this up so that future deflate changes will apply properly: - the compressed_len accounting is a debug-only change as it is only ever read inside DEBUG tracing. - remove the dead #ifdef STORED_FILE_OK block in zlib_tr_flush_block() The kernel is now in sync with zlib commit 14763ac7c6c0 ("zlib 1.1.3"), for real this time. Signed-off-by: Greg Kroah-Hartman --- lib/zlib_deflate/deftree.c | 41 ++++++++++++++++------------------------- lib/zlib_deflate/defutil.h | 2 +- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/lib/zlib_deflate/deftree.c b/lib/zlib_deflate/deftree.c index d4107392d70c..baa8d37fd094 100644 --- a/lib/zlib_deflate/deftree.c +++ b/lib/zlib_deflate/deftree.c @@ -244,8 +244,6 @@ void zlib_tr_init( { tr_static_init(); - s->compressed_len = 0L; - s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; @@ -259,6 +257,7 @@ void zlib_tr_init( s->bi_valid = 0; s->last_eob_len = 8; /* enough lookahead for inflate */ #ifdef DEBUG_ZLIB + s->compressed_len = 0L; s->bits_sent = 0L; #endif @@ -744,9 +743,10 @@ void zlib_tr_stored_block( ) { send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ +#ifdef DEBUG_ZLIB s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; - +#endif copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } @@ -758,7 +758,9 @@ void zlib_tr_stored_type_only( { send_bits(s, (STORED_BLOCK << 1), 3); bi_windup(s); +#ifdef DEBUG_ZLIB s->compressed_len = (s->compressed_len + 3) & ~7L; +#endif } @@ -779,7 +781,9 @@ void zlib_tr_align( { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG_ZLIB s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif bi_flush(s); /* Of the 10 bits for the empty block, we have already sent * (10 - bi_valid) bits. The lookahead for the last real code (before @@ -789,7 +793,9 @@ void zlib_tr_align( if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG_ZLIB s->compressed_len += 10L; +#endif bi_flush(s); } s->last_eob_len = 7; @@ -800,7 +806,7 @@ void zlib_tr_align( * trees or store, and output the encoded block to the zip file. This function * returns the total compressed length for the file so far. */ -ulg zlib_tr_flush_block( +void zlib_tr_flush_block( deflate_state *s, char *buf, /* input block, or NULL if too old */ ulg stored_len, /* length of input block */ @@ -849,25 +855,6 @@ ulg zlib_tr_flush_block( opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } - /* If compression failed and this is the first and last block, - * and if the .zip file can be seeked (to rewrite the local header), - * the whole file is transformed into a stored file: - */ -#ifdef STORED_FILE_OK -# ifdef FORCE_STORED_FILE - if (eof && s->compressed_len == 0L) { /* force stored file */ -# else - if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) { -# endif - /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ - if (buf == (char*)0) error ("block vanished"); - - copy_block(s, buf, (unsigned)stored_len, 0); /* without header */ - s->compressed_len = stored_len << 3; - s->method = STORED; - } else -#endif /* STORED_FILE_OK */ - #ifdef FORCE_STORED if (buf != (char*)0) { /* force stored block */ #else @@ -889,25 +876,29 @@ ulg zlib_tr_flush_block( #endif send_bits(s, (STATIC_TREES<<1)+eof, 3); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG_ZLIB s->compressed_len += 3 + s->static_len; +#endif } else { send_bits(s, (DYN_TREES<<1)+eof, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG_ZLIB s->compressed_len += 3 + s->opt_len; +#endif } Assert (s->compressed_len == s->bits_sent, "bad compressed size"); init_block(s); if (eof) { bi_windup(s); +#ifdef DEBUG_ZLIB s->compressed_len += 7; /* align on byte boundary */ +#endif } Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*eof)); - - return s->compressed_len >> 3; } /* =========================================================================== diff --git a/lib/zlib_deflate/defutil.h b/lib/zlib_deflate/defutil.h index b639235c4fa6..29fa51e32da1 100644 --- a/lib/zlib_deflate/defutil.h +++ b/lib/zlib_deflate/defutil.h @@ -279,7 +279,7 @@ typedef struct deflate_state { /* in trees.c */ void zlib_tr_init (deflate_state *s); int zlib_tr_tally (deflate_state *s, unsigned dist, unsigned lc); -ulg zlib_tr_flush_block (deflate_state *s, char *buf, ulg stored_len, +void zlib_tr_flush_block (deflate_state *s, char *buf, ulg stored_len, int eof); void zlib_tr_align (deflate_state *s); void zlib_tr_stored_block (deflate_state *s, char *buf, ulg stored_len, -- 2.56.1