zsh-workers
 help / color / mirror / code / Atom feed
From: Kamil Dudka <kdudka@redhat.com>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: zsh-workers@zsh.org, Oliver Kiddle <okiddle@yahoo.co.uk>
Subject: Re: [PATCH v2] {,un}applychange: do not call zle_setline(NULL) if quietgethist() fails
Date: Fri, 26 Jul 2019 17:24:59 +0200	[thread overview]
Message-ID: <14924445.cisvKSXWIz@nbkamil> (raw)
In-Reply-To: <20190723134548.10998-1-kdudka@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1444 bytes --]

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;
>      }

[-- Attachment #2: 0001-zle_utils-fix-incorrect-use-of-dputs.patch --]
[-- Type: text/x-patch, Size: 1210 bytes --]

From 97c195f6de8c566e88c0bb753aadc8217dc37875 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
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


      reply	other threads:[~2019-07-26 15:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-26 10:19 [PATCH] " Kamil Dudka
     [not found] ` <249696510.1723352.1561545091592@mail2.virginmedia.com>
2019-06-26 11:00   ` Fwd: " Peter Stephenson
2019-06-26 12:07     ` Kamil Dudka
2019-06-27 23:01 ` Oliver Kiddle
2019-06-28  0:20   ` Mikael Magnusson
2019-06-28  8:12   ` Kamil Dudka
2019-07-23 13:45   ` [PATCH v2] " Kamil Dudka
2019-07-26 15:24     ` Kamil Dudka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14924445.cisvKSXWIz@nbkamil \
    --to=kdudka@redhat.com \
    --cc=okiddle@yahoo.co.uk \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).