xsel

Program for manipulating the X clipboard
git clone https://git.sinitax.com/kfish/xsel
Log | Files | Refs | README | LICENSE | sfeed.txt

commit c760ace62ac4fe1cf65d88475d5939c1aa360d6b
parent e251314099ecd2d68106cf67fa8ae5f2d8756607
Author: Anton Lindqvist <anton.lindqvist@gmail.com>
Date:   Thu, 25 Aug 2016 21:06:44 +0200

Fix segfault when stdin is empty

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.

Diffstat:
Mxsel.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xsel.c b/xsel.c @@ -949,7 +949,7 @@ initialise_read (unsigned char * read_buffer) int insize = in_statbuf.st_blksize; unsigned char * new_buffer = NULL; - if (S_ISREG (in_statbuf.st_mode)) { + if (S_ISREG (in_statbuf.st_mode) && in_statbuf.st_size > 0) { current_alloc += in_statbuf.st_size; } else { current_alloc += insize;