Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] fix use of uninitialized memory contents in prompttrunc()
- X-seq: zsh-workers 40260
- From: Kamil Dudka <kdudka@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] fix use of uninitialized memory contents in prompttrunc()
- Date: Tue, 3 Jan 2017 12:29:34 +0100
- Cc: Paulo Andrade <pandrade@xxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Paulo Andrade <pandrade@xxxxxxxxxx>
... which may crash Zsh under certain circumstances
Originally reported at https://bugzilla.redhat.com/1408619
A valgrind report captured with zsh-5.3.1-6-g4fb4ce1 follows:
Conditional jump or move depends on uninitialised value(s)
at 0x4C2EBD8: strlen (vg_replace_strmem.c:454)
by 0x18A302: prompttrunc (prompt.c:1471)
by 0x188F62: putpromptchar (prompt.c:589)
by 0x18A0BD: prompttrunc (prompt.c:1515)
by 0x188F62: putpromptchar (prompt.c:589)
by 0x189BA5: promptexpand (prompt.c:215)
by 0x127CE0: bin_print (builtin.c:4270)
by 0x12CCC4: execbuiltin (builtin.c:485)
by 0x13AE81: execcmd_exec (exec.c:3854)
by 0x13B9D1: execpline2 (exec.c:1861)
by 0x13BDEB: execpline (exec.c:1591)
by 0x13D753: execlist (exec.c:1349)
Conditional jump or move depends on uninitialised value(s)
at 0x18A33F: prompttrunc (prompt.c:1477)
by 0x188F62: putpromptchar (prompt.c:589)
by 0x18A0BD: prompttrunc (prompt.c:1515)
by 0x188F62: putpromptchar (prompt.c:589)
by 0x189BA5: promptexpand (prompt.c:215)
by 0x127CE0: bin_print (builtin.c:4270)
by 0x12CCC4: execbuiltin (builtin.c:485)
by 0x13AE81: execcmd_exec (exec.c:3854)
by 0x13B9D1: execpline2 (exec.c:1861)
by 0x13BDEB: execpline (exec.c:1591)
by 0x13D753: execlist (exec.c:1349)
by 0x160E75: execfor (loop.c:175)
---
Src/prompt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/prompt.c b/Src/prompt.c
index ee77c8b..29e006e 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -920,6 +920,7 @@ addbufspc(int need)
if(need & 255)
need = (need | 255) + 1;
bv->buf = realloc(bv->buf, bv->bufspc += need);
+ memset(bv->buf + bv->bufspc - need, 0, need);
bv->bp = bv->buf + bo;
if(bo1 != -1)
bv->bp1 = bv->buf + bo1;
--
2.7.4
Messages sorted by:
Reverse Date,
Date,
Thread,
Author