Bug 1055409

Summary: clear_history cause segfault.
Product: [Fedora] Fedora Reporter: Remi Collet <fedora>
Component: libeditAssignee: Kamil Dudka <kdudka>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jeff, kdudka, loganjerry
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libedit-3.1-4.20130712cvs.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-21 14:36:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Remi Collet 2014-01-20 08:06:07 UTC
Simple test script, raising the segfault:

#include <editline/readline.h>
int main (int argc, char *argv[]) {
  clear_history();
  return 0;
}

Of course using_history() should be called first.

On PHP side, calling using_history during module init is not perfect as it raise some issue: https://bugs.php.net/65714

Studying libedit code, each *_history function start with a check (eq to using_history function)

        if (h == NULL || e == NULL)
                rl_initialize();

The clear_history is the only function where this check is missing.
Of course, this have be workaround in php, https://bugs.php.net/66412

I think it will be more secure to add this check.

Comment 1 Kamil Dudka 2014-01-21 13:22:20 UTC
Thanks!  I have forwarded your proposal to libedit upstream as a patch.

Comment 2 Kamil Dudka 2014-01-21 14:36:59 UTC
fixed in libedit-3.1-4.20130712cvs.fc21