NetBSD Problem Report #37165
From sjamaan@frohike.homeunix.org Sun Oct 21 11:02:30 2007
Return-Path: <sjamaan@frohike.homeunix.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id C8C2C63B934
for <gnats-bugs@gnats.NetBSD.org>; Sun, 21 Oct 2007 11:02:29 +0000 (UTC)
Message-Id: <20071021110131.3E26BF7DFA4@frohike.homeunix.org>
Date: Sun, 21 Oct 2007 13:01:31 +0200 (CEST)
From: Peter.Bex@xs4all.nl
Reply-To: Peter.Bex@xs4all.nl
To: gnats-bugs@NetBSD.org
Subject: ksh history mechanism off-by-one error
X-Send-Pr-Version: 3.95
>Number: 37165
>Category: bin
>Synopsis: The ksh has an off-by-one error when changing the history size
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 21 11:05:00 +0000 2007
>Originator: Peter Bex
>Release: NetBSD 4.0_RC1
>Organization:
N/A
>Environment:
System: NetBSD byers.homeunix.org 4.0_RC1 NetBSD 4.0_RC1 (GENERIC) #1: Mon Oct 15 22:43:12 CEST 2007 sjamaan@byers.homeunix.org:/usr/src/sys/arch/macppc/compile/GENERIC macppc
Architecture: powerpc
Machine: macppc
>Description:
When resizing the history size in /bin/ksh using the HISTSIZE
variable, there is an off-by-one error when it sets the history
pointer. This causes an error when scrolling through the
buffer.
>How-To-Repeat:
ksh
$ echo "something to put in the history buffer"
$ HISTSIZE=1
$ <ctrl+p or escape+p, depending on editing mode>
ksh: internal error: grabhist: bad history array
or:
ksh
$ HISTSIZE=2
$ HISTSIZE=1
$ <ctrl+p or escape+p, depending on editing mode>
HISTSIZE=1 <again ctrl+p/escape+p>
HISTSIZE=2
I have also observed segfaults in older ksh versions, but this looks
like it has been fixed from NetBSD 3.0 -> 4.0.
>Fix:
The ksh code is pretty opaque, but as far as I have been able to determine,
this fixes the problem and introduces no new ones:
Index: history.c
===================================================================
RCS file: /cvsroot/src/bin/ksh/history.c,v
retrieving revision 1.9
diff -u -r1.9 history.c
--- history.c 26 Jun 2005 19:09:00 -0000 1.9
+++ history.c 18 Oct 2007 19:37:42 -0000
@@ -552,7 +552,7 @@
histlist = (char **)aresize(histlist, n*sizeof(char *), APERM);
histsize = n;
- histptr = histlist + cursize;
+ histptr = histlist + cursize - 1;
}
}
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.