diff options
| author | 2010-02-01 18:29:37 +0100 | |
|---|---|---|
| committer | 2010-02-01 18:29:37 +0100 | |
| commit | 003e72659b579e4376d099767f2e757e80d8f2a4 (patch) | |
| tree | 1c8559a59a764d63c0462f4beb103cb72deb3d12 /daemon/device.c | |
| parent | 9932ebe49a47c929c8345625a907e5d4e73fe3d5 (diff) | |
| download | usbmuxd-003e72659b579e4376d099767f2e757e80d8f2a4.tar.gz usbmuxd-003e72659b579e4376d099767f2e757e80d8f2a4.tar.bz2 | |
Don't crash on TCP junk during device init
Diffstat (limited to 'daemon/device.c')
| -rw-r--r-- | daemon/device.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/daemon/device.c b/daemon/device.c index 759cb91..824edac 100644 --- a/daemon/device.c +++ b/daemon/device.c | |||
| @@ -461,12 +461,18 @@ static void device_version_input(struct mux_device *dev, struct version_header * | |||
| 461 | 461 | ||
| 462 | static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned char *payload, uint32_t payload_length) | 462 | static void device_tcp_input(struct mux_device *dev, struct tcphdr *th, unsigned char *payload, uint32_t payload_length) |
| 463 | { | 463 | { |
| 464 | usbmuxd_log(LL_DEBUG, "[IN] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", | ||
| 465 | dev->id, ntohs(th->th_sport), ntohs(th->th_dport), ntohl(th->th_seq), ntohl(th->th_ack), th->th_flags, ntohs(th->th_win) << 8, ntohs(th->th_win), payload_length); | ||
| 466 | |||
| 467 | uint16_t sport = ntohs(th->th_dport); | 464 | uint16_t sport = ntohs(th->th_dport); |
| 468 | uint16_t dport = ntohs(th->th_sport); | 465 | uint16_t dport = ntohs(th->th_sport); |
| 469 | struct mux_connection *conn = NULL; | 466 | struct mux_connection *conn = NULL; |
| 467 | |||
| 468 | usbmuxd_log(LL_DEBUG, "[IN] dev=%d sport=%d dport=%d seq=%d ack=%d flags=0x%x window=%d[%d] len=%d", | ||
| 469 | dev->id, dport, sport, ntohl(th->th_seq), ntohl(th->th_ack), th->th_flags, ntohs(th->th_win) << 8, ntohs(th->th_win), payload_length); | ||
| 470 | |||
| 471 | if(dev->state != MUXDEV_ACTIVE) { | ||
| 472 | usbmuxd_log(LL_ERROR, "Received TCP packet from device %d but the device isn't active yet, discarding\n", dev->id); | ||
| 473 | return; | ||
| 474 | } | ||
| 475 | |||
| 470 | FOREACH(struct mux_connection *lconn, &dev->connections) { | 476 | FOREACH(struct mux_connection *lconn, &dev->connections) { |
| 471 | if(lconn->sport == sport && lconn->dport == dport) { | 477 | if(lconn->sport == sport && lconn->dport == dport) { |
| 472 | conn = lconn; | 478 | conn = lconn; |
