From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24668 invoked from network); 18 Sep 2008 09:40:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Sep 2008 09:40:36 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 22512 invoked from network); 18 Sep 2008 09:40:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Sep 2008 09:40:23 -0000 Received: (qmail 17354 invoked by alias); 18 Sep 2008 09:40:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25682 Received: (qmail 17339 invoked from network); 18 Sep 2008 09:40:17 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 Sep 2008 09:40:17 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 6C6E880308BA for ; Thu, 18 Sep 2008 11:40:06 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly24g.srv.mailcontrol.com (MailControl) with ESMTP id m8I9dq3i020397 for ; Thu, 18 Sep 2008 10:40:03 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 18 Sep 2008 10:39:59 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m8I9drMD008369 for ; Thu, 18 Sep 2008 10:39:54 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m8I9drfd008366 for ; Thu, 18 Sep 2008 10:39:53 +0100 X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: zshaddhistory hook can get unterminated string X-Mailer: MH-E 8.0.3; nmh 1.3; GNU Emacs 22.1.1 Date: Thu, 18 Sep 2008 10:39:53 +0100 Message-ID: <8365.1221730793@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 18 Sep 2008 09:39:59.0074 (UTC) FILETIME=[8424CC20:01C91972] X-Scanned-By: MailControl A-08-50-14 (www.mailcontrol.com) on 10.71.0.134 X-Virus-Scanned: ClamAV 0.92.1/8277/Thu Sep 18 10:36:44 2008 on bifrost X-Virus-Status: Clean There are now hook functions called when a history line is about to be saved. I've seen these getting garbage at the end of the argument passed in, which is the line about to be processed for saving. This is presumably because the history line hasn't been terminated. I haven't verified that fixing this makes the problem go away (it's intermittent), but it seems like the right thing to do anyway. Index: Src/hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hist.c,v retrieving revision 1.83 diff -u -r1.83 hist.c --- Src/hist.c 10 Sep 2008 19:02:27 -0000 1.83 +++ Src/hist.c 18 Sep 2008 09:34:49 -0000 @@ -1129,7 +1129,13 @@ if (hist_ignore_all_dups != isset(HISTIGNOREALLDUPS) && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0) histremovedups(); - + + /* + * Added the following in case the test "hptr < chline + 1" + * is more than just paranoia. + */ + DPUTS(hptr < chline, "History end pointer off start of line"); + *hptr = '\0'; addlinknode(hookargs, "zshaddhistory"); addlinknode(hookargs, chline); callhookfunc("zshaddhistory", hookargs, 1, &hookret); @@ -1144,7 +1150,6 @@ if (hptr < chline + 1) save = 0; else { - *hptr = '\0'; if (hptr[-1] == '\n') { if (chline[1]) { *--hptr = '\0'; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070