bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

8.2-rc4 replace_history entry() missing check for NULL


From: Ondřej Novák
Subject: 8.2-rc4 replace_history entry() missing check for NULL
Date: Tue, 20 Sep 2022 11:14:39 +0200

This bug is there for a long time

Version: 8.2-rc4
OS: Linux, Ubuntu 22, amd64
Description:

The function replace_history_entry() doesn't check for NULL at line history.c:400

  temp->line = savestring (line);
  temp->data = "">  ----> temp->timestamp = savestring (old_value->timestamp); <<-----------
  the_history[which] = temp;

If the timestamp is NULL, it causes SIGSEGV. However, there are many checks in other functions, for example, the function copy_history_entry() has such a check, and the function history_get_time()  checks timestamp for NULL as well, so I can assume that timestamp can be NULL. Unfortunately, this function is specially called from readline_internal_teardown() which makes use of timestamps mandatory.

Reproduction steps:

1] Forge own HISTSTATE with history allocated using alloc_history_entry, passing NULL as a timestamp. 
2] use history_set_history_state for your state
3] call readline()
4] choose any history item, modify it and press enter
5] SIGSEGV

Fix:
temp->timestamp = old_value->timestamp?savestring (old_value->timestamp):0;

Ondřej Novák




reply via email to

[Prev in Thread] Current Thread [Next in Thread]