Bug 117348 - [libedit] Loading history file sometimes fails in libedit
Summary: [libedit] Loading history file sometimes fails in libedit
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 6.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-20 00:10 UTC by Martin Beran
Modified: 2017-08-27 01:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Beran 2007-10-20 00:10:02 UTC
Under some circumstances, loading history in libedit by history(H_LOAD)
causes abnormal program termination due to invalid memory access on line
693 of /usr/src/lib/libedit/history.c.

Fix: 

Compile the following program with ElectricFence
#include <histedit.h>
int main(int argc, char* argv[])
{
    History* h = history_init();
    HistEvent ev;
    history(h, &ev, H_LOAD, argv[1]);
    return 0;
}
and run it with a history file 4096 bytes long containing
_HiStOrY_V2_
def0123456789abcdef0123456789abcdef0123456789abcde
followed by 63 copies of line:
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde