mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-02 22:29:25 +00:00
Check device messages assumptions at runtime
Do not assume the server behaves correctly (scrcpy should not require the device to be trusted).
This commit is contained in:
parent
d894e270a7
commit
295102a6d9
1 changed files with 11 additions and 1 deletions
|
@ -43,9 +43,19 @@ process_msg(struct sc_receiver *receiver, struct sc_device_msg *msg) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEVICE_MSG_TYPE_ACK_CLIPBOARD:
|
case DEVICE_MSG_TYPE_ACK_CLIPBOARD:
|
||||||
assert(receiver->acksync);
|
|
||||||
LOGD("Ack device clipboard sequence=%" PRIu64_,
|
LOGD("Ack device clipboard sequence=%" PRIu64_,
|
||||||
msg->ack_clipboard.sequence);
|
msg->ack_clipboard.sequence);
|
||||||
|
|
||||||
|
// This is a programming error to receive this message if there is
|
||||||
|
// no ACK synchronization mechanism
|
||||||
|
assert(receiver->acksync);
|
||||||
|
|
||||||
|
// Also check at runtime (do not trust the server)
|
||||||
|
if (!receiver->acksync) {
|
||||||
|
LOGE("Received unexpected ack");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sc_acksync_ack(receiver->acksync, msg->ack_clipboard.sequence);
|
sc_acksync_ack(receiver->acksync, msg->ack_clipboard.sequence);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue