1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

unix: don't use usb_hid_write from usb_hid_read for PING/PONG

This commit is contained in:
Pavol Rusnak 2018-01-17 23:38:25 +01:00
parent fea8d53b85
commit 3098dc8447
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -105,8 +105,10 @@ int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
slen = sl;
static const char *ping_req = "PINGPING";
static const char *ping_resp = "PONGPONG";
if (r == strlen(ping_req) && memcmp(ping_req, buf, strlen(ping_req)) == 0) {
ensure(usb_hid_write(0, (const uint8_t *)ping_resp, strlen(ping_resp)), "usb_hid_write");
if (r == strlen(ping_req) && 0 == memcmp(ping_req, buf, strlen(ping_req))) {
if (slen > 0) {
sendto(sock, ping_resp, strlen(ping_resp), MSG_DONTWAIT, (const struct sockaddr *)&si_other, slen);
}
return 0;
}
return r;