From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 83cb3ba2 for ; Fri, 26 Jul 2019 15:25:51 +0000 (UTC) Received: (qmail 13892 invoked by alias); 26 Jul 2019 15:25:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44582 Received: (qmail 6614 invoked by uid 1010); 26 Jul 2019 15:25:40 -0000 X-Qmail-Scanner-Diagnostics: from mx1.redhat.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25517. spamassassin: 3.4.2. Clear:RC:0(209.132.183.28):SA:0(-6.9/5.0):. Processed in 1.137149 secs); 26 Jul 2019 15:25:40 -0000 X-Envelope-From: kdudka@redhat.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) From: Kamil Dudka To: Peter Stephenson Cc: zsh-workers@zsh.org, Oliver Kiddle Subject: Re: [PATCH v2] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails Date: Fri, 26 Jul 2019 17:24:59 +0200 Message-ID: <14924445.cisvKSXWIz@nbkamil> In-Reply-To: <20190723134548.10998-1-kdudka@redhat.com> References: <797-1561676485.902916@C-Cf.WCnE.5Cn6> <20190723134548.10998-1-kdudka@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart6438204.QVv33f76Ck" Content-Transfer-Encoding: 7Bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 26 Jul 2019 15:25:00 +0000 (UTC) --nextPart6438204.QVv33f76Ck Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sorry, I used dputs() incorrectly, which caused undefined symbols in a non-debug build. The attached patch fixes it. Sorry for the troubles! Kamil On Tuesday, July 23, 2019 3:45:48 PM CEST Kamil Dudka wrote: > There is a bug report in Red Hat Bugzilla about zsh crashing on NULL > pointer dereference: https://bugzilla.redhat.com/1722703 > > I was not able to reproduce the crash myself but the attached patch > should prevent zsh from crashing in this situation. > --- > Src/Zle/zle_utils.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c > index 0277d4917..d549b885b 100644 > --- a/Src/Zle/zle_utils.c > +++ b/Src/Zle/zle_utils.c > @@ -1607,7 +1607,12 @@ static int > unapplychange(struct change *ch) > { > if(ch->hist != histline) { > - zle_setline(quietgethist(ch->hist)); > + Histent he = quietgethist(ch->hist); > + if(!he) { > + dputs(ERRMSG("quietgethist(ch->hist) returned NULL")); > + return 1; > + } > + zle_setline(he); > zlecs = ch->new_cs; > return 0; > } > @@ -1647,7 +1652,12 @@ static int > applychange(struct change *ch) > { > if(ch->hist != histline) { > - zle_setline(quietgethist(ch->hist)); > + Histent he = quietgethist(ch->hist); > + if(!he) { > + dputs(ERRMSG("quietgethist(ch->hist) returned NULL")); > + return 1; > + } > + zle_setline(he); > zlecs = ch->old_cs; > return 0; > } --nextPart6438204.QVv33f76Ck Content-Disposition: attachment; filename="0001-zle_utils-fix-incorrect-use-of-dputs.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-zle_utils-fix-incorrect-use-of-dputs.patch" >From 97c195f6de8c566e88c0bb753aadc8217dc37875 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Fri, 26 Jul 2019 17:17:40 +0200 Subject: [PATCH] zle_utils: fix incorrect use of dputs() ... that caused undefined symbols in a non-debug build --- Src/Zle/zle_utils.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index d549b885b..2b306fdcd 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1608,10 +1608,9 @@ unapplychange(struct change *ch) { if(ch->hist != histline) { Histent he = quietgethist(ch->hist); - if(!he) { - dputs(ERRMSG("quietgethist(ch->hist) returned NULL")); + DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL"); + if(he == NULL) return 1; - } zle_setline(he); zlecs = ch->new_cs; return 0; @@ -1653,10 +1652,9 @@ applychange(struct change *ch) { if(ch->hist != histline) { Histent he = quietgethist(ch->hist); - if(!he) { - dputs(ERRMSG("quietgethist(ch->hist) returned NULL")); + DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL"); + if(he == NULL) return 1; - } zle_setline(he); zlecs = ch->old_cs; return 0; -- 2.20.1 --nextPart6438204.QVv33f76Ck--