xsel

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

commit b1a9e3da61f816ac560f3f5af95950e507967ad9
parent 9674445d8ea9f60f4d1a154be6fdb12e7af8f0c6
Author: Conrad Parker <conrad@metadecks.org>
Date:   Fri, 12 Aug 2016 04:55:48 +1000

Merge pull request #16 from ebiggers/master

INCR transfer bug fixes
Diffstat:
Mxsel.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xsel.c b/xsel.c @@ -620,14 +620,15 @@ get_append_property (XSelectionEvent * xsl, unsigned char ** buffer, print_debug (D_TRACE, "Got zero length property; end of INCR transfer"); return False; } else if (format == 8) { - if (*offset + length > *alloc) { - *alloc = *offset + length; + if (*offset + length + 1 > *alloc) { + *alloc = *offset + length + 1; if ((*buffer = realloc (*buffer, *alloc)) == NULL) { exit_err ("realloc error"); } } ptr = *buffer + *offset; - xs_strncpy (ptr, value, length); + memcpy (ptr, value, length); + ptr[length] = '\0'; *offset += length; print_debug (D_TRACE, "Appended %d bytes to buffer\n", length); } else { @@ -1299,13 +1300,13 @@ change_property (Display * display, Window requestor, Atom property, print_debug (D_TRACE, "large data transfer"); - /* Send a SelectionNotify event of type INCR */ + /* Send a SelectionNotify event */ ev.type = SelectionNotify; ev.display = display; ev.requestor = requestor; ev.selection = selection; ev.time = time; - ev.target = incr_atom; /* INCR */ + ev.target = target; ev.property = property; XSelectInput (ev.display, ev.requestor, PropertyChangeMask);