diff options
| author | 2008-08-06 21:04:09 -0700 | |
|---|---|---|
| committer | 2008-08-06 21:04:09 -0700 | |
| commit | bef655966045af34e1f20a7211f0cab2e7e79001 (patch) | |
| tree | 590b41891fab48af0c3f35431f7476bbc2b4b0a2 /src/usbmux.c | |
| parent | d81a3c5c412cca9b8327d6d27625bc52650e9651 (diff) | |
| download | libimobiledevice-bef655966045af34e1f20a7211f0cab2e7e79001.tar.gz libimobiledevice-bef655966045af34e1f20a7211f0cab2e7e79001.tar.bz2 | |
Adds locking and fixes a minor bug in mux_recv
Signed-off-by: Matt Colyer <matt@colyer.name>
Diffstat (limited to 'src/usbmux.c')
| -rw-r--r-- | src/usbmux.c | 9 |
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; |
