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) {
for (i = 0; i < connections; i++) {
if (connlist[i]->header->sport == header->dport && connlist[i]->header->dport == header->sport) {
// we have a winner.
+ char *nfb = (char*)malloc(sizeof(char) * (connlist[i]->r_len + (bytes - 28)));
+ if (connlist[i]->recv_buffer && connlist[i]->r_len) {
+ memcpy(nfb, connlist[i]->recv_buffer, connlist[i]->r_len);
+ free(connlist[i]->recv_buffer);
+ }
connlist[i]->r_len += bytes - 28;
- connlist[i]->recv_buffer = (char*)realloc(connlist[i]->recv_buffer, sizeof(char) * connection->r_len); // grow their buffer
+ //connlist[i]->recv_buffer = (char*)realloc(connlist[i]->recv_buffer, sizeof(char) * connection->r_len); // grow their buffer
+ connlist[i]->recv_buffer = nfb;
+ nfb = NULL; // A cookie for you if you can guess what "nfb" means.
complex = connlist[i]->r_len - (bytes - 28);
memcpy(connlist[i]->recv_buffer+complex, buffer+28, bytes-28); // paste into their buffer
connlist[i]->header->ocnt += bytes-28;