From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23923 invoked by alias); 22 Jul 2015 14:00:15 -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: X-Seq: 35855 Received: (qmail 14804 invoked from network); 22 Jul 2015 14:00:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.0 From: Kamil Dudka To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: infinite recursion in ihungetc() Date: Wed, 22 Jul 2015 16:00:10 +0200 Message-ID: <2667649.zUoaYM3Kd9@kdudka.brq.redhat.com> User-Agent: KMail/4.14.9 (Linux/4.0.8-304.fc22.x86_64; KDE/4.14.9; x86_64; ; ) In-Reply-To: <20150722143803.1be07f1e@pwslap01u.europe.root.pri> References: <2874073.clZcYqQZLr@kdudka.brq.redhat.com> <20150722143803.1be07f1e@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 On Wednesday 22 July 2015 14:38:03 Peter Stephenson wrote: > Yes, it should be straightforward to prevent, although this code isn't > particularly transparent (or new), so I don't know how you could get > there. > > pws I do not know it either because these crash reports are anonymous. I will just apply your patch to fix it and let you know if we get any feedback. Thanks for the patch! Kamil > diff --git a/Src/hist.c b/Src/hist.c > index 6725313..cf224cb 100644 > --- a/Src/hist.c > +++ b/Src/hist.c > @@ -136,6 +136,7 @@ mod_export int hist_skip_flags; > #define HA_NOINC (1<<1) /* Don't store, curhist not incremented */ > #define HA_INWORD (1<<2) /* We're inside a word, don't add > start and end markers */ > +#define HA_UNGET (1<<3) /* Recursively ungetting */ > > /* Array of word beginnings and endings in current history line. */ > > @@ -904,8 +905,13 @@ ihungetc(int c) > > while (!lexstop && !errflag) { > if (hptr[-1] != (char) c && stophist < 4 && > - hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\') > - hungetc('\n'), hungetc('\\'); > + hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\' && > + !(histactive & HA_UNGET)) { > + histactive |= HA_UNGET; > + hungetc('\n'); > + hungetc('\\'); > + histactive &= ~HA_UNGET; > + } > > if (expanding) { > zlemetacs--;