Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault when stdin is empty #17

Merged
merged 1 commit into from
Sep 2, 2016
Merged

Fix segfault when stdin is empty #17

merged 1 commit into from
Sep 2, 2016

Conversation

mptre
Copy link
Contributor

@mptre mptre commented Aug 28, 2016

When reading input from stdin, ensure the initial read buffer capacity
is greater than zero. This prevents the program from crashing when
writing the null terminator to the buffer in read_input.

How to reproduce:

$ touch empty
$ xsel <empty
Segmentation fault (core dumped)
$ gdb -c xsel.core xsel
#0  0x0000046261b0381b in read_input (read_buffer=0x464b8715bb0 <Address 0x464b8715bb0 out of bounds>, do_select=0) at xsel.c:918
918       read_buffer[total_input] = '\0';

When reading input from stdin, ensure the initial read buffer capacity
is greater than zero. This prevents the program from crashing when
writing the null terminator to the buffer in read_input.
@kfish kfish merged commit aa7f57e into kfish:master Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants