summaryrefslogtreecommitdiffstats
path: root/src/usbmux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usbmux.c')
-rw-r--r--src/usbmux.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/usbmux.c b/src/usbmux.c
index 235a1f2..d79ee47 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -301,8 +301,15 @@ int mux_recv(usbmux_connection *connection, char *data, uint32 datalen) {
301 for (i = 0; i < connections; i++) { 301 for (i = 0; i < connections; i++) {
302 if (connlist[i]->header->sport == header->dport && connlist[i]->header->dport == header->sport) { 302 if (connlist[i]->header->sport == header->dport && connlist[i]->header->dport == header->sport) {
303 // we have a winner. 303 // we have a winner.
304 char *nfb = (char*)malloc(sizeof(char) * (connlist[i]->r_len + (bytes - 28)));
305 if (connlist[i]->recv_buffer && connlist[i]->r_len) {
306 memcpy(nfb, connlist[i]->recv_buffer, connlist[i]->r_len);
307 free(connlist[i]->recv_buffer);
308 }
304 connlist[i]->r_len += bytes - 28; 309 connlist[i]->r_len += bytes - 28;
305 connlist[i]->recv_buffer = (char*)realloc(connlist[i]->recv_buffer, sizeof(char) * connection->r_len); // grow their buffer 310 //connlist[i]->recv_buffer = (char*)realloc(connlist[i]->recv_buffer, sizeof(char) * connection->r_len); // grow their buffer
311 connlist[i]->recv_buffer = nfb;
312 nfb = NULL; // A cookie for you if you can guess what "nfb" means.
306 complex = connlist[i]->r_len - (bytes - 28); 313 complex = connlist[i]->r_len - (bytes - 28);
307 memcpy(connlist[i]->recv_buffer+complex, buffer+28, bytes-28); // paste into their buffer 314 memcpy(connlist[i]->recv_buffer+complex, buffer+28, bytes-28); // paste into their buffer
308 connlist[i]->header->ocnt += bytes-28; 315 connlist[i]->header->ocnt += bytes-28;