Skip to content

Commit

Permalink
fix(android.c): fix empty or invalid clipboard request handling
Browse files Browse the repository at this point in the history
  • Loading branch information
twaik authored Nov 27, 2024
1 parent 3f15378 commit 7402905
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/cpp/lorie/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ Java_com_termux_x11_LorieView_handleXEvents(JNIEnv *env, jobject thiz) {
if (read(conn_fd, &e, sizeof(e)) == sizeof(e)) {
switch(e.type) {
case EVENT_CLIPBOARD_SEND: {
if (!e.clipboardSend.count)
break;
char clipboard[e.clipboardSend.count + 1];
memset(clipboard, 0, e.clipboardSend.count + 1);
read(conn_fd, clipboard, sizeof(clipboard));
clipboard[e.clipboardSend.count] = 0;
log(DEBUG, "Clipboard content (%zu symbols) is %s", strlen(clipboard), clipboard);
Expand Down

0 comments on commit 7402905

Please sign in to comment.