diff options
| -rw-r--r-- | src/AFC.c | 4 | ||||
| -rw-r--r-- | src/ifuse.c | 3 | ||||
| -rw-r--r-- | src/initconf.c | 26 | ||||
| -rw-r--r-- | src/iphone.c | 5 | ||||
| -rw-r--r-- | src/lockdown.c | 15 | ||||
| -rw-r--r-- | src/usbmux.c | 2 | ||||
| -rw-r--r-- | src/userpref.c | 3 |
7 files changed, 37 insertions, 21 deletions
| @@ -20,7 +20,7 @@ | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include "AFC.h" | 22 | #include "AFC.h" |
| 23 | 23 | #include "plist.h" | |
| 24 | // This is the maximum size an AFC data packet can be | 24 | // This is the maximum size an AFC data packet can be |
| 25 | const int MAXIMUM_PACKET_SIZE = (2 << 15) - 32; | 25 | const int MAXIMUM_PACKET_SIZE = (2 << 15) - 32; |
| 26 | 26 | ||
| @@ -211,7 +211,7 @@ static int receive_AFC_data(AFClient *client, char **dump_here) { | |||
| 211 | break; | 211 | break; |
| 212 | } | 212 | } |
| 213 | if (strstr(buffer, "CFA6LPAA")) { | 213 | if (strstr(buffer, "CFA6LPAA")) { |
| 214 | if (debug) printf("receive_AFC_data: WARNING: there is AFC data in this packet at %i\n", strstr(buffer, "CFA6LPAA") - buffer); | 214 | if (debug) printf("receive_AFC_data: WARNING: there is AFC data in this packet at %ti\n", strstr(buffer, "CFA6LPAA") - buffer); |
| 215 | if (debug) printf("receive_AFC_data: the total packet length is %i\n", bytes); | 215 | if (debug) printf("receive_AFC_data: the total packet length is %i\n", bytes); |
| 216 | //continue; // but we do need to continue because packets/headers != data | 216 | //continue; // but we do need to continue because packets/headers != data |
| 217 | } | 217 | } |
diff --git a/src/ifuse.c b/src/ifuse.c index aa06070..6a24bad 100644 --- a/src/ifuse.c +++ b/src/ifuse.c | |||
| @@ -194,7 +194,7 @@ void *ifuse_init(struct fuse_conn_info *conn) { | |||
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | host_id = get_host_id(); | 196 | host_id = get_host_id(); |
| 197 | if (host_id && !lockdownd_start_SSL_session(control, host_id) || !host_id) { | 197 | if ((host_id && !lockdownd_start_SSL_session(control, host_id)) || !host_id) { |
| 198 | fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n"); | 198 | fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n"); |
| 199 | return NULL; | 199 | return NULL; |
| 200 | } | 200 | } |
| @@ -263,7 +263,6 @@ int ifuse_truncate(const char *path, off_t size) { | |||
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) { | 265 | int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) { |
| 266 | int result = 0; | ||
| 267 | AFClient *afc = fuse_get_context()->private_data; | 266 | AFClient *afc = fuse_get_context()->private_data; |
| 268 | AFCFile *file = g_hash_table_lookup(file_handles, &fi->fh); | 267 | AFCFile *file = g_hash_table_lookup(file_handles, &fi->fh); |
| 269 | if (!file) return -ENOENT; | 268 | if (!file) return -ENOENT; |
diff --git a/src/initconf.c b/src/initconf.c index be697e8..0149ac9 100644 --- a/src/initconf.c +++ b/src/initconf.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
| 24 | #include <gnutls/gnutls.h> | 24 | #include <gnutls/gnutls.h> |
| 25 | #include <gnutls/x509.h> | ||
| 25 | #include <glib.h> | 26 | #include <glib.h> |
| 26 | #include "userpref.h" | 27 | #include "userpref.h" |
| 27 | 28 | ||
| @@ -54,6 +55,7 @@ int main(int argc, char *argv[]) { | |||
| 54 | 55 | ||
| 55 | gnutls_global_init(); | 56 | gnutls_global_init(); |
| 56 | 57 | ||
| 58 | size_t size; | ||
| 57 | char* host_id = NULL; //"29942970-207913891623273984" | 59 | char* host_id = NULL; //"29942970-207913891623273984" |
| 58 | gnutls_x509_privkey_t root_privkey; | 60 | gnutls_x509_privkey_t root_privkey; |
| 59 | gnutls_x509_privkey_t host_privkey; | 61 | gnutls_x509_privkey_t host_privkey; |
| @@ -99,26 +101,34 @@ int main(int argc, char *argv[]) { | |||
| 99 | gnutls_datum_t root_key_pem = {NULL, 0}; | 101 | gnutls_datum_t root_key_pem = {NULL, 0}; |
| 100 | gnutls_datum_t host_key_pem = {NULL, 0}; | 102 | gnutls_datum_t host_key_pem = {NULL, 0}; |
| 101 | 103 | ||
| 102 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, NULL, &root_key_pem.size); | 104 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, NULL, &size); |
| 103 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_pem.size); | 105 | root_key_pem.size = size; |
| 106 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, NULL, &size); | ||
| 107 | host_key_pem.size = size; | ||
| 104 | 108 | ||
| 105 | root_key_pem.data = gnutls_malloc(root_key_pem.size); | 109 | root_key_pem.data = gnutls_malloc(root_key_pem.size); |
| 106 | host_key_pem.data = gnutls_malloc(host_key_pem.size); | 110 | host_key_pem.data = gnutls_malloc(host_key_pem.size); |
| 107 | 111 | ||
| 108 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &root_key_pem.size); | 112 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &size); |
| 109 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &host_key_pem.size); | 113 | root_key_pem.size = size; |
| 114 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &size); | ||
| 115 | host_key_pem.size = size; | ||
| 110 | 116 | ||
| 111 | gnutls_datum_t root_cert_pem = {NULL, 0}; | 117 | gnutls_datum_t root_cert_pem = {NULL, 0}; |
| 112 | gnutls_datum_t host_cert_pem = {NULL, 0}; | 118 | gnutls_datum_t host_cert_pem = {NULL, 0}; |
| 113 | 119 | ||
| 114 | gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, NULL, &root_cert_pem.size); | 120 | gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, NULL, &size); |
| 115 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_pem.size); | 121 | root_cert_pem.size = size; |
| 122 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, NULL, &size); | ||
| 123 | host_cert_pem.size = size; | ||
| 116 | 124 | ||
| 117 | root_cert_pem.data = gnutls_malloc(root_cert_pem.size); | 125 | root_cert_pem.data = gnutls_malloc(root_cert_pem.size); |
| 118 | host_cert_pem.data = gnutls_malloc(host_cert_pem.size); | 126 | host_cert_pem.data = gnutls_malloc(host_cert_pem.size); |
| 119 | 127 | ||
| 120 | gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &root_cert_pem.size); | 128 | gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &size); |
| 121 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &host_cert_pem.size); | 129 | root_cert_pem.size = size; |
| 130 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &size); | ||
| 131 | host_cert_pem.size = size; | ||
| 122 | 132 | ||
| 123 | 133 | ||
| 124 | /* store values in config file */ | 134 | /* store values in config file */ |
diff --git a/src/iphone.c b/src/iphone.c index 426b629..558dd9a 100644 --- a/src/iphone.c +++ b/src/iphone.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | #include "usbmux.h" | 22 | #include "usbmux.h" |
| 23 | #include "iphone.h" | 23 | #include "iphone.h" |
| 24 | #include <arpa/inet.h> | ||
| 24 | #include <usb.h> | 25 | #include <usb.h> |
| 25 | #include <stdio.h> | 26 | #include <stdio.h> |
| 26 | #include <stdlib.h> | 27 | #include <stdlib.h> |
| @@ -141,13 +142,13 @@ int send_to_phone(iPhone *phone, char *data, int datalen) { | |||
| 141 | if (!phone) return -1; | 142 | if (!phone) return -1; |
| 142 | int bytes = 0; | 143 | int bytes = 0; |
| 143 | // it may die here | 144 | // it may die here |
| 144 | if (debug) printf("dying here?\ndatalen = %i\ndata = %x\n", datalen, data); | 145 | if (debug) printf("dying here?\ndatalen = %i\ndata = %p\n", datalen, data); |
| 145 | 146 | ||
| 146 | bytes = usb_bulk_write(phone->device, BULKOUT, data, datalen, 800); | 147 | bytes = usb_bulk_write(phone->device, BULKOUT, data, datalen, 800); |
| 147 | if (debug) printf("noooo...?\n"); | 148 | if (debug) printf("noooo...?\n"); |
| 148 | if (bytes < datalen) { | 149 | if (bytes < datalen) { |
| 149 | if(debug && bytes < 0) | 150 | if(debug && bytes < 0) |
| 150 | printf("send_to_iphone(): libusb gave me the error %d: %s\n", bytes, usb_strerror(), strerror(-bytes)); | 151 | printf("send_to_iphone(): libusb gave me the error %d: %s - %s\n", bytes, usb_strerror(), strerror(-bytes)); |
| 151 | return -1; | 152 | return -1; |
| 152 | } else { | 153 | } else { |
| 153 | return bytes; | 154 | return bytes; |
diff --git a/src/lockdown.c b/src/lockdown.c index 78ab6a9..7f938fb 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
| @@ -23,10 +23,12 @@ | |||
| 23 | #include "iphone.h" | 23 | #include "iphone.h" |
| 24 | #include "lockdown.h" | 24 | #include "lockdown.h" |
| 25 | #include "userpref.h" | 25 | #include "userpref.h" |
| 26 | #include <arpa/inet.h> | ||
| 26 | #include <errno.h> | 27 | #include <errno.h> |
| 27 | #include <string.h> | 28 | #include <string.h> |
| 28 | #include <glib.h> | 29 | #include <glib.h> |
| 29 | #include <libtasn1.h> | 30 | #include <libtasn1.h> |
| 31 | #include <gnutls/x509.h> | ||
| 30 | 32 | ||
| 31 | extern int debug; | 33 | extern int debug; |
| 32 | 34 | ||
| @@ -446,9 +448,12 @@ int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char * | |||
| 446 | /* if everything went well, export in PEM format */ | 448 | /* if everything went well, export in PEM format */ |
| 447 | 449 | ||
| 448 | gnutls_datum_t dev_pem = {NULL, 0}; | 450 | gnutls_datum_t dev_pem = {NULL, 0}; |
| 449 | gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, NULL, &dev_pem.size); | 451 | size_t crt_size; |
| 452 | gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, NULL, &crt_size); | ||
| 453 | dev_pem.size = crt_size; | ||
| 450 | dev_pem.data = gnutls_malloc(dev_pem.size); | 454 | dev_pem.data = gnutls_malloc(dev_pem.size); |
| 451 | gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_pem.data, &dev_pem.size); | 455 | gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_pem.data, &crt_size); |
| 456 | dev_pem.size = crt_size; | ||
| 452 | 457 | ||
| 453 | /* now encode certificates for output */ | 458 | /* now encode certificates for output */ |
| 454 | *device_cert_b64 = g_base64_encode(dev_pem.data, dev_pem.size); | 459 | *device_cert_b64 = g_base64_encode(dev_pem.data, dev_pem.size); |
| @@ -583,7 +588,7 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size | |||
| 583 | lockdownd_client *control; | 588 | lockdownd_client *control; |
| 584 | control = (lockdownd_client*)transport; | 589 | control = (lockdownd_client*)transport; |
| 585 | if (debug) printf("lockdownd_secuwrite() called\n"); | 590 | if (debug) printf("lockdownd_secuwrite() called\n"); |
| 586 | if (debug) printf("pre-send\nlength = %i\n", length); | 591 | if (debug) printf("pre-send\nlength = %zi\n", length); |
| 587 | bytes = mux_send(control->connection, buffer, length); | 592 | bytes = mux_send(control->connection, buffer, length); |
| 588 | if (debug) printf("post-send\nsent %i bytes\n", bytes); | 593 | if (debug) printf("post-send\nsent %i bytes\n", bytes); |
| 589 | if (debug) { | 594 | if (debug) { |
| @@ -602,7 +607,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 602 | char *hackhackhack = NULL; | 607 | char *hackhackhack = NULL; |
| 603 | lockdownd_client *control; | 608 | lockdownd_client *control; |
| 604 | control = (lockdownd_client*)transport; | 609 | control = (lockdownd_client*)transport; |
| 605 | if (debug) printf("lockdownd_securead() called\nlength = %i\n", length); | 610 | if (debug) printf("lockdownd_securead() called\nlength = %zi\n", length); |
| 606 | // Buffering hack! Throw what we've got in our "buffer" into the stream first, then get more. | 611 | // Buffering hack! Throw what we've got in our "buffer" into the stream first, then get more. |
| 607 | if (control->gtls_buffer_hack_len > 0) { | 612 | if (control->gtls_buffer_hack_len > 0) { |
| 608 | if (length > control->gtls_buffer_hack_len) { // If it's asking for more than we got | 613 | if (length > control->gtls_buffer_hack_len) { // If it's asking for more than we got |
| @@ -633,7 +638,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_ | |||
| 633 | // End buffering hack! | 638 | // End buffering hack! |
| 634 | char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens | 639 | char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens |
| 635 | 640 | ||
| 636 | if (debug) printf("pre-read\nclient wants %i bytes\n", length); | 641 | if (debug) printf("pre-read\nclient wants %zi bytes\n", length); |
| 637 | bytes = mux_recv(control->connection, recv_buffer, (length * 1000)); | 642 | bytes = mux_recv(control->connection, recv_buffer, (length * 1000)); |
| 638 | if (debug) printf("post-read\nwe got %i bytes\n", bytes); | 643 | if (debug) printf("post-read\nwe got %i bytes\n", bytes); |
| 639 | if (debug && bytes < 0) { | 644 | if (debug && bytes < 0) { |
diff --git a/src/usbmux.c b/src/usbmux.c index d79ee47..83797dd 100644 --- a/src/usbmux.c +++ b/src/usbmux.c | |||
| @@ -200,7 +200,7 @@ int mux_send(usbmux_connection *connection, const char *data, uint32 datalen) { | |||
| 200 | memcpy(buffer+sizeof(usbmux_tcp_header), data, datalen); | 200 | memcpy(buffer+sizeof(usbmux_tcp_header), data, datalen); |
| 201 | 201 | ||
| 202 | // We have a buffer full of data, we should now send it to the phone. | 202 | // We have a buffer full of data, we should now send it to the phone. |
| 203 | if (debug) printf("actually sending %i bytes of data at %x\n", sizeof(usbmux_tcp_header)+datalen, buffer); | 203 | if (debug) printf("actually sending %zi bytes of data at %p\n", sizeof(usbmux_tcp_header)+datalen, buffer); |
| 204 | 204 | ||
| 205 | 205 | ||
| 206 | bytes = send_to_phone(connection->phone, buffer, sizeof(usbmux_tcp_header)+datalen); | 206 | bytes = send_to_phone(connection->phone, buffer, sizeof(usbmux_tcp_header)+datalen); |
diff --git a/src/userpref.c b/src/userpref.c index cd29c43..49a3c45 100644 --- a/src/userpref.c +++ b/src/userpref.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <glib.h> | 22 | #include <glib.h> |
| 23 | #include <glib/gprintf.h> | ||
| 23 | #include <stdio.h> | 24 | #include <stdio.h> |
| 24 | #include <string.h> | 25 | #include <string.h> |
| 25 | #include "userpref.h" | 26 | #include "userpref.h" |
| @@ -140,7 +141,7 @@ int store_device_public_key(char* public_key) | |||
| 140 | g_io_channel_shutdown(file, TRUE, NULL); | 141 | g_io_channel_shutdown(file, TRUE, NULL); |
| 141 | 142 | ||
| 142 | /* append device to list */ | 143 | /* append device to list */ |
| 143 | gchar** new_devices_list = (gchar**)g_malloc(sizeof(gchar*)* (length + 2)); | 144 | const gchar** new_devices_list = (const gchar**)g_malloc(sizeof(gchar*)* (length + 2)); |
| 144 | int i; | 145 | int i; |
| 145 | for( i = 0; i < length; i++) | 146 | for( i = 0; i < length; i++) |
| 146 | new_devices_list[i] = devices_list[i]; | 147 | new_devices_list[i] = devices_list[i]; |
