srfsh can segfault if .srfsh_history is empty

Bug #1461978 reported by Galen Charlton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
Confirmed
Undecided
Unassigned

Bug Description

If ~/.srfsh_history is empty (as might happen if one cleared the request history by cat'ing /dev/null into it), using readline commands to try to retrieve history items causes srfsh to segfault.

For example:

$ cat /dev/null > ~/.srfsh_history
$ srfsh # then hit the up arrow key

OpenSRF master

Tags: pullrequest
Revision history for this message
Galen Charlton (gmc) wrote :

Note that a segfault does not happen if ~/.srfsh_history was not present to begin with.

description: updated
Revision history for this message
Galen Charlton (gmc) wrote :

Some more details:

Platform: Debian 7.8

Back trace of the segfault:

#0 0x00007fa21ff88adc in previous_history () from /lib/x86_64-linux-gnu/libreadline.so.5
#1 0x00007fa21ff88645 in rl_get_previous_history () from /lib/x86_64-linux-gnu/libreadline.so.5
#2 0x00007fa21ff716a0 in _rl_dispatch_subseq () from /lib/x86_64-linux-gnu/libreadline.so.5
#3 0x00007fa21ff718d1 in _rl_dispatch_subseq () from /lib/x86_64-linux-gnu/libreadline.so.5
#4 0x00007fa21ff718d1 in _rl_dispatch_subseq () from /lib/x86_64-linux-gnu/libreadline.so.5
#5 0x00007fa21ff71c60 in readline_internal_char () from /lib/x86_64-linux-gnu/libreadline.so.5
#6 0x00007fa21ff72105 in readline () from /lib/x86_64-linux-gnu/libreadline.so.5
#7 0x00000000004026b4 in get_request () at srfsh.c:242
#8 main (argc=<optimized out>, argv=<optimized out>) at srfsh.c:165

libreadline6 package version: 6.2+dfsg-0.1

Revision history for this message
Jason Boyer (jboyer) wrote :

There's a fix for this here: https://git.evergreen-ils.org/?p=working/OpenSRF.git;a=shortlog;h=refs/heads/user/jboyer/lp1461978_history_segfault / working/user/jboyer/lp1461978_history_segfault

Testing notes:
1. Pre-patch, setup OpenSRF and srfsh so srfsh can be used successfully
2. Set $HOME/.srfsh_history to a 0 size with truncate or create it with touch
3. run srfsh and press the up arrow to try to retrieve a history entry
4. Segfault

Apply patch and repeat steps above. This time step 4 should be "Become annoyed at the BEL being sent through your speakers."

Jason Boyer (jboyer)
tags: added: pullrequest
Changed in opensrf:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.