hstr icon indicating copy to clipboard operation
hstr copied to clipboard

program crashes on favorite add

Open juppytt opened this issue 1 year ago • 2 comments

  1. Prepare a zsh history file (~/.zsh_history) that contains an entry such as vim ~/.zsh_history
  2. Run hstr by ./src/hstr AAAAAA
  3. Add a new favorite from history (Ctrl-J then Ctrl-F)
  4. Clear the command buffer and search the entry from history (Ctrl-U, Z, Ctrl-J) => this searches vim ~/.zsh_history and selects the entry
  5. Invalidate search result by changing to exact match and favorites view (Ctrl-E, Ctrl-Slash, Ctrl-Slash)
  6. There is no matching entry but try to select an empty entry and add it to the favorite (Ctrl-J then Ctrl-F)
  7. Crashes on accessing a null pointer

poc

Stopped reason: SIGSEGV
0x00007ffff7ce8891 in ?? () from /usr/lib/x86_64-linux-gnu/libc.so.6
gdb-peda$ bt
#0  0x00007ffff7ce8891 in ?? () from /usr/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7c0100a in strcasestr () from /usr/lib/x86_64-linux-gnu/libc.so.6
#2  0x00005555555ff3f1 in __interceptor_strcasestr (s1=s1@entry=0x0, s2=0x7ffff5900030 "B")
    at /home/juhee/project/foxfuzz/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:688
#3  0x0000555555678615 in hstr_make_selection (prefix=<optimized out>, history=<optimized out>, maxSelectionCount=0x39) at hstr.c:935
#4  0x0000555555679605 in hstr_print_selection (maxHistoryItems=<optimized out>, pattern=<optimized out>) at hstr.c:1066
#5  0x000055555567be9c in loop_to_select () at hstr.c:1403
#6  0x000055555567d6fa in hstr_interactive () at hstr.c:1660
#7  0x000055555567dcce in hstr_main (argc=0x2, argv=0x7fffffffe058) at hstr.c:1744
#8  0x00007ffff7b84083 in __libc_start_main () from /usr/lib/x86_64-linux-gnu/libc.so.6
#9  0x000055555557559e in _start ()

File: ~/.zsh_history

1670224747:0;vim ~/.zsh_history

juppytt avatar Dec 05 '22 08:12 juppytt