zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] fix use of uninitialized memory contents in prompttrunc()
@ 2017-01-03 11:29 Kamil Dudka
  0 siblings, 0 replies; only message in thread
From: Kamil Dudka @ 2017-01-03 11:29 UTC (permalink / raw)
  To: zsh-workers; +Cc: Paulo Andrade

From: Paulo Andrade <pandrade@redhat.com>

... 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-03 11:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-03 11:29 [PATCH] fix use of uninitialized memory contents in prompttrunc() Kamil Dudka

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).