From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Zsh parser segmentation fault in putpromptchar putpromptchar at prompt.c
Date: Tue, 09 May 2017 09:30:06 +0100 [thread overview]
Message-ID: <20170509093006.7c2d676c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAOSMAuv62M+tmz4J+j5zOVTSV6gMiK8RLTu6MAQSO4tcT-qgiw@mail.gmail.com>
On Mon, 8 May 2017 13:42:46 -0500
Eduardo Bustamante <dualbus@gmail.com> wrote:
> dualbus@debian:~/bash-fuzzing/zsh-parser$ base64 segfault
> JHsoJVUpWS0lKHZ9
>
> dualbus@debian:~/bash-fuzzing/zsh-parser$ md5sum segfault
> 0d79a8c613315f32a453d5aa07a7de65 segfault
>
> dualbus@debian:~/bash-fuzzing/zsh-parser$ cat -v segfault
> ${(%U)Y-%(v}
The test for psvar is wrong if it's empty.
pws
diff --git a/Src/prompt.c b/Src/prompt.c
index 29e006e..c478e69 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -399,7 +399,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
test = 1;
break;
case 'V':
- if (arrlen_ge(psvar, arg)) {
+ if (psvar && *psvar && arrlen_ge(psvar, arg)) {
if (*psvar[(arg ? arg : 1) - 1])
test = 1;
}
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 0818728..11f18dc 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -209,3 +209,7 @@
print -P -f '%%Sfoo%%s\n' bar
0:print -P -f
>%Sfoo%s
+
+ print ${(%U)Y-%(v}
+0:Regression test for test on empty psvar
+>
prev parent reply other threads:[~2017-05-09 8:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170508184346epcas2p364369da57566738a36b888054303eee5@epcas2p3.samsung.com>
2017-05-08 18:42 ` Eduardo Bustamante
2017-05-09 8:30 ` Peter Stephenson [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=20170509093006.7c2d676c@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.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).