summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/idevice.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/idevice.c b/src/idevice.c
index 1958bdf..87ed87c 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -33,6 +33,9 @@
33#ifdef WIN32 33#ifdef WIN32
34#include <winsock2.h> 34#include <winsock2.h>
35#include <windows.h> 35#include <windows.h>
36#else
37#include <sys/socket.h>
38#include <netinet/in.h>
36#endif 39#endif
37 40
38#include <usbmuxd.h> 41#include <usbmuxd.h>
@@ -324,7 +327,21 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_in
324 newlist[newcount]->conn_data = NULL; 327 newlist[newcount]->conn_data = NULL;
325 } else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK) { 328 } else if (dev_list[i].conn_type == CONNECTION_TYPE_NETWORK) {
326 newlist[newcount]->conn_type = CONNECTION_NETWORK; 329 newlist[newcount]->conn_type = CONNECTION_NETWORK;
327 size_t addrlen = ((uint8_t*)dev_list[i].conn_data)[0]; 330 struct sockaddr* saddr = (struct sockaddr*)(dev_list[i].conn_data);
331 size_t addrlen = 0;
332 switch (saddr->sa_family) {
333 case AF_INET:
334 addrlen = sizeof(struct sockaddr_in);
335 break;
336#ifdef AF_INET6
337 case AF_INET6:
338 addrlen = sizeof(struct sockaddr_in6);
339 break;
340#endif
341 default:
342 debug_info("Unsupported address family 0x%02x\n", saddr->sa_family);
343 continue;
344 }
328 newlist[newcount]->conn_data = malloc(addrlen); 345 newlist[newcount]->conn_data = malloc(addrlen);
329 memcpy(newlist[newcount]->conn_data, dev_list[i].conn_data, addrlen); 346 memcpy(newlist[newcount]->conn_data, dev_list[i].conn_data, addrlen);
330 } 347 }
@@ -426,9 +443,25 @@ static idevice_t idevice_from_mux_device(usbmuxd_device_info_t *muxdev)
426 break; 443 break;
427 case CONNECTION_TYPE_NETWORK: 444 case CONNECTION_TYPE_NETWORK:
428 device->conn_type = CONNECTION_NETWORK; 445 device->conn_type = CONNECTION_NETWORK;
429 size_t len = ((uint8_t*)muxdev->conn_data)[0]; 446 struct sockaddr* saddr = (struct sockaddr*)(muxdev->conn_data);
430 device->conn_data = malloc(len); 447 size_t addrlen = 0;
431 memcpy(device->conn_data, muxdev->conn_data, len); 448 switch (saddr->sa_family) {
449 case AF_INET:
450 addrlen = sizeof(struct sockaddr_in);
451 break;
452#ifdef AF_INET6
453 case AF_INET6:
454 addrlen = sizeof(struct sockaddr_in6);
455 break;
456#endif
457 default:
458 debug_info("Unsupported address family 0x%02x\n", saddr->sa_family);
459 free(device->udid);
460 free(device);
461 return NULL;
462 }
463 device->conn_data = malloc(addrlen);
464 memcpy(device->conn_data, muxdev->conn_data, addrlen);
432 break; 465 break;
433 default: 466 default:
434 device->conn_type = 0; 467 device->conn_type = 0;