NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/53981: libedit: history_list should null-terminate
>Number: 53981
>Category: lib
>Synopsis: libedit: history_list should null-terminate
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 14 19:10:00 +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;
}
Home |
Main Index |
Thread Index |
Old Index