[PATCH] fix segfault

11 views
Skip to first unread message

Richard Kolkovich

unread,
Dec 14, 2010, 1:39:51 PM12/14/10
to keynav...@googlegroups.com
Resurrecting my keynav use, I found a segfault processing defaults(). strtok_r returns NULL when
the keysequence has no commands (i.e. clear). I *am* on FreeBSD, but I'm not sure how this hasn't
affected anyone else, as the Linux strtok_r(2) states the same behavior...

Cheers,
Richard

--

Richard Kolkovich
http://www.sigil.org
PGP Key: 0x9E54EF59 (http://pgp.mit.edu)

keynav-segfault.patch

Jordan Sissel

unread,
Dec 24, 2010, 10:37:29 PM12/24/10
to keynav...@googlegroups.com
On Tue, Dec 14, 2010 at 10:39 AM, Richard Kolkovich <ric...@sigil.org> wrote:
> Resurrecting my keynav use, I found a segfault processing defaults().  strtok_r returns NULL when
> the keysequence has no commands (i.e. clear).  I *am* on FreeBSD, but I'm not sure how this hasn't
> affected anyone else, as the Linux strtok_r(2) states the same behavior...
>
> Cheers,
> Richard
>

I can confirm the crash on FreeBSD, and it doesn't crash on Linux
(Ubuntu 10.04).

The documentation is for strtok_r is incomplete. Both FreeBSD and
glibc document the behavior of the return value, but not the value of
the context pointer ('last' in freebsd, 'saveptr' in glibc).

I wrote some test code: https://gist.github.com/754661
Summary: Nobody agrees on behavior. Frankly, I think glibc's behavior
is correct, here, but since nobody documents it, I'll work around it.

-Jordan

Jordan Sissel

unread,
Dec 24, 2010, 10:51:17 PM12/24/10
to keynav...@googlegroups.com

New version with a fix:
http://semicomplete.googlecode.com/files/keynav-0.20101224.3183.tar.gz

I added error checking along with this -
% ./keynav
Incomplete configuration line. Missing commands: 'ctrl+a'
Error with config /home/jls//.keynavrc:18: ctrl+a

Can you test and confirm?

-Jordan

Reply all
Reply to author
Forward
0 new messages