From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 02 11:22:17 2023 Received: (at submit) by debbugs.gnu.org; 2 Jun 2023 15:22:17 +0000 Received: from localhost ([127.0.0.1]:40655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q56bV-0001Rs-WE for submit@debbugs.gnu.org; Fri, 02 Jun 2023 11:22:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:49928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q52jz-0006Yz-Ec for submit@debbugs.gnu.org; Fri, 02 Jun 2023 07:14:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q52jx-00062J-Nl for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 07:14:42 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q52jt-0007nu-LA for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 07:14:39 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-64d18d772bdso2242734b3a.3 for ; Fri, 02 Jun 2023 04:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685704475; x=1688296475; h=content-transfer-encoding:to:message-id:thread-topic:subject:from :date:mime-version:from:to:cc:subject:date:message-id:reply-to; bh=R9PJhj6aPfkS0N5v8uyTpTczn2Kl5rjm0RFrK4Tv5P0=; b=YCMG7x4aXRl8uwQsPM/67haQMSrP/xXAiMkhvs7IOTt5pW3735VOz96MCeVWovYNrB J88xPYfEghTc2Yeyt9zmh4r809U8nW5i4QLQGDaiMfU12cznpWLB28/pKVq16QaIQ818 ZkpDWPSE7j81aq+8JTAJPvEYUpj2+xuWNbPTK6gpmIXbal4kcms6Oa/xJlZiE0L8b7Ym fOF6OlhUTgdtftCsRo7Q5cr+ATQvwp/EkKjhwqeSCiXFsXV/gkRKL4vPZKdzqobvHTH0 Uq0UY6CTtNOlAaL4Y5K6nXd20teFY6ssgHMI9z3FcZzR+mnTS6TIgAeVXtYgEv9/00w0 MsiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685704475; x=1688296475; h=content-transfer-encoding:to:message-id:thread-topic:subject:from :date:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=R9PJhj6aPfkS0N5v8uyTpTczn2Kl5rjm0RFrK4Tv5P0=; b=FNOtSElWRmow0La9JWHQXeN6TU1jYfxLO2ivhFVJM+thHBRCKFyPJqzC2+wHBKtoWw DBHLih96Hr7yfmHINhtvKev79h80/GjO4mEoKikLvQDPwQ/bNrrFmpj+PPBbLKgy+EBm RVT4Ya5Xdh67RQTTqeo4v4/5dyj2BY74nvg7ucMSUiP54YRVyiM+jTP/FRg43n270+hY w+/h4Yy2FQ13VkDYsE+5kPJHohSdmBp1j92vHmgFa7DVyka9oOVPFUQBGk68QzWnQsGO rhoJ9SpVQDQoA0ZcBrKIofA8panZEOlQwsdsnigj9dBysM2ZalkVT0secnmf357JcvrH 59lg== X-Gm-Message-State: AC+VfDycr/eZfD0kWJO2nTX6ceWvCjcx0SukkriuCXLCQ7m0GJe1B67V 4ae/QjIpWKUzjYkIPv/4lzYK9jrOeyHlrg== X-Google-Smtp-Source: ACHHUZ5OdO102/QfLUUgpOZcADLrmFOjt2oTmhYmpU1185QkOq5A9kOaRwbQO3vCV2mkf28qWnTDdQ== X-Received: by 2002:a05:6a00:1745:b0:643:59cd:6cad with SMTP id j5-20020a056a00174500b0064359cd6cadmr15706389pfc.24.1685704474975; Fri, 02 Jun 2023 04:14:34 -0700 (PDT) Received: from CortexAuth ([49.42.35.87]) by smtp.gmail.com with ESMTPSA id l3-20020a62be03000000b0063afb08afeesm825360pff.67.2023.06.02.04.14.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2023 04:14:34 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 2 Jun 2023 16:44:25 +0530 From: cortexauth Subject: [PATCH] Incorrect usage of inflate() from zlib in decompress.c Thread-Topic: [PATCH] Incorrect usage of inflate() from zlib in decompress.c Message-ID: To: "bug-gnu-emacs@gnu.org" Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=deepak.takumi.120@gmail.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 02 Jun 2023 11:22:12 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--)

Hey t= here,

 

Whi= le building Emacs one of my friends encountered a bug where entering certai= n commands such as `M-x eww RET`
After some digging in, we found this wa= s because of Z_BUF_ERROR arising in decompress.c:150

Per the docs (<= a href=3D"https://refspecs.linuxbase.org/LSB_3.0.0/LSB-Core-generic/LSB-Cor= e-generic/zlib-inflate-1.html">inflate (linuxbase.org)) this happens wh= en either of in or out buffer runs out and there is no further possible pro= gress

The code makes a wrong assumption that IF `stream.avail_out` i= s zero, we can keep on inflating. It=E2=80=99s possible for `stream.avail_i= n` and `stream.avail_out` to be both zero at the same time (I don=E2=80=99t= have a minimalistic test case for this yet, but I am sure that one can con= struct this with some thought)

Following is the patch for the fix
--
--- a/src/decompress.c

+++ b/= src/decompress.c

@@ -151,7 +151,7 @@ md5= _gz_stream (FILE *source, void *resblock)

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -1;

 

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 accumulate_and_process_md5 (out, MD5_BLOCKSIZE - stre= am.avail_out, &ctx);

-=C2=A0=C2=A0= =C2=A0 } while (stream.avail_in && !stream.avail_out);

+=C2=A0=C2=A0=C2=A0 } while (!stream.avail_out);

 

= =C2=A0=C2=A0 } while (res !=3D Z_STREAM_END);
--

This is also my = first time contributing so I might have made mistakes in making a good patc= h (one is obviously my incapability to quickly think of minimal test case),= so I will appreciate suggestions

=  

Thanks,

Deepak Sharma

= From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 02 11:34:44 2023 Received: (at 63848) by debbugs.gnu.org; 2 Jun 2023 15:34:44 +0000 Received: from localhost ([127.0.0.1]:40692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q56nc-0001qQ-0K for submit@debbugs.gnu.org; Fri, 02 Jun 2023 11:34:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39774) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q56nY-0001q7-56; Fri, 02 Jun 2023 11:34:42 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q56nS-0002mE-OD; Fri, 02 Jun 2023 11:34:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=8GqwIacCvj1TQms1WFbQ112jrvrYQk4YPyIenP7VuEM=; b=hyuhMfbYMjKdqvq7nlTH hWjN+vIqO4ZiFnMlZos45eaVKAE6OpgRhKaq6EU2F1fJg1Uzljuoh2dCrUZXkfq/lMb6PFToqY9Pe wOL5oSRx75mFZ5Cmy+uEPidGIcMLQwa0thS9nhP2gg2i7J6uYBqapl94nIIcyROy0BesR5KG7oYPo yVtf7w4md5/XO+AoRofYjYsK8y+i/HRClPJeysQcxLxQfpr+vE5vSQR+eBsrH6LWqPlgs7qpJ8eoB iRLDPNevlk/YcPxQsa1me8fuPA1o52sdTxq9R/B4IR6pozBL5eCUjveUYn6FR7L7FOMT3uplL2A5G BFiLo0v/I5fnbQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q56nO-0001YB-6n; Fri, 02 Jun 2023 11:34:34 -0400 Date: Fri, 02 Jun 2023 18:35:18 +0300 Message-Id: <83sfb9and5.fsf@gnu.org> From: Eli Zaretskii To: cortexauth In-Reply-To: (message from cortexauth on Fri, 2 Jun 2023 16:44:25 +0530) Subject: Re: bug#63848: [PATCH] Incorrect usage of inflate() from zlib in decompress.c References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63848 Cc: 63848@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) merge 63848 63832 thanks > Date: Fri, 2 Jun 2023 16:44:25 +0530 > From: cortexauth > > While building Emacs one of my friends encountered a bug where entering certain commands such as > `M-x eww RET` > After some digging in, we found this was because of Z_BUF_ERROR arising in decompress.c:150 > > Per the docs (inflate (linuxbase.org)) this happens when either of in or out buffer runs out and there is > no further possible progress > > The code makes a wrong assumption that IF `stream.avail_out` is zero, we can keep on inflating. It’s > possible for `stream.avail_in` and `stream.avail_out` to be both zero at the same time (I don’t have a > minimalistic test case for this yet, but I am sure that one can construct this with some thought) > > Following is the patch for the fix > > -- > --- a/src/decompress.c > > +++ b/src/decompress.c > > @@ -151,7 +151,7 @@ md5_gz_stream (FILE *source, void *resblock) > > return -1; > > > > accumulate_and_process_md5 (out, MD5_BLOCKSIZE - stream.avail_out, &ctx); > > - } while (stream.avail_in && !stream.avail_out); > > + } while (!stream.avail_out); > > > > } while (res != Z_STREAM_END); > -- > > This is also my first time contributing so I might have made mistakes in making a good patch (one is > obviously my incapability to quickly think of minimal test case), so I will appreciate suggestions Another duplicate of bug#63832. From unknown Sat Aug 16 16:06:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 06 Jul 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 01 01:36:25 2023 Received: (at control) by debbugs.gnu.org; 1 Aug 2023 05:36:25 +0000 Received: from localhost ([127.0.0.1]:46964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQi3V-0001Pk-Jn for submit@debbugs.gnu.org; Tue, 01 Aug 2023 01:36:25 -0400 Received: from dev.gentoo.org ([2001:470:ea4a:1:5054:ff:fec7:86e4]:51703 helo=smtp.gentoo.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQi3U-0001PW-Aj for control@debbugs.gnu.org; Tue, 01 Aug 2023 01:36:24 -0400 From: Ulrich Mueller To: control@debbugs.gnu.org Subject: unarchive 63832 Date: Tue, 01 Aug 2023 07:36:12 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) unarchive 63832 thank you From unknown Sat Aug 16 16:06:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 29 Aug 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator