commit cc44281dbb214fd41702e2499168748e7d4c0a37
parent 4c8c317633bef98e8f2d7b25476a25a64e62b951
Author: Eric Biggers <ebiggers3@gmail.com>
Date: Sun, 6 Mar 2016 11:54:54 -0600
Do not prematurely terminate string while receiving INCR transfer
This fixes a bug where xsel would only output the first 3999 characters
of the selection.
Diffstat:
1 file changed, 4 insertions(+), 3 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 {