NetBSD Problem Report #53981
From www@NetBSD.org Thu Feb 14 19:08:26 2019
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 10A447A1EE
for <gnats-bugs@gnats.NetBSD.org>; Thu, 14 Feb 2019 19:08:26 +0000 (UTC)
Message-Id: <20190214190825.34EEB7A1EE@mollari.NetBSD.org>
Date: Thu, 14 Feb 2019 19:08:25 +0000 (UTC)
From: jperkins+netbsd@google.com
Reply-To: jperkins+netbsd@google.com
To: gnats-bugs@NetBSD.org
Subject: libedit: history_list should null-terminate
X-Send-Pr-Version: www-1.0
>Number: 53981
>Category: lib
>Synopsis: libedit: history_list should null-terminate
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 14 19:10:00 +0000 2019
>Closed-Date: Thu Feb 14 23:15:36 +0000 2019
>Last-Modified: Thu Feb 14 23:15:36 +0000 2019
>Originator: Jonathan Perkins
>Release: Sources as of 2019/02/14
>Organization:
Google
>Environment:
>Description:
Readline documents that history_list is null-terminated. At present, history_list in libedit doesn't null-terminate; it'd be helpful to add the null terminator for compatibility.
This can be addressed with a small change to _history_listp, as indicated in the proposed patch.
(this is one of a few issues I've run into trying to reach readline compatibility, I'll submit more patches if this is helpful)
>How-To-Repeat:
On calling history_list(), iterator through the HIST_ENTRY**, looking for a null terminator.
>Fix:
--- old/src/readline.c
+++ new/src/readline.c
@@ -1600,7 +1600,7 @@ history_list(void)
return NULL;
if ((nlp = el_realloc(_history_listp,
- (size_t)history_length * sizeof(*nlp))) == NULL)
+ ((size_t)history_length + 1) * sizeof(*nlp))) == NULL)
return NULL;
_history_listp = nlp;
@@ -1617,6 +1617,7 @@ history_list(void)
if (i++ == history_length)
abort();
} while (history(h, &ev, H_PREV) == 0);
+ _history_listp[i] = NULL;
return _history_listp;
}
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/53981 CVS commit: src/lib/libedit
Date: Thu, 14 Feb 2019 15:09:12 -0500
Module Name: src
Committed By: christos
Date: Thu Feb 14 20:09:12 UTC 2019
Modified Files:
src/lib/libedit: readline.c
Log Message:
PR/53981: Jonathan Perkins: history_list should null-terminate
To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/lib/libedit/readline.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Thu, 14 Feb 2019 23:15:36 +0000
State-Changed-Why:
Fixed by christos, thanks!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.