diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/afc.c | 34 | ||||
-rw-r--r-- | src/idevice.c | 76 | ||||
-rw-r--r-- | src/lockdown.c | 20 | ||||
-rw-r--r-- | src/misagent.c | 3 | ||||
-rw-r--r-- | src/mobileactivation.c | 15 | ||||
-rw-r--r-- | src/mobilebackup2.c | 9 | ||||
-rw-r--r-- | src/preboard.c | 3 | ||||
-rw-r--r-- | src/restore.c | 18 | ||||
-rw-r--r-- | src/syslog_relay.c | 9 |
9 files changed, 93 insertions, 94 deletions
@@ -229,7 +229,9 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t | |||
229 | if (recv_len == 0) { | 229 | if (recv_len == 0) { |
230 | debug_info("Just didn't get enough."); | 230 | debug_info("Just didn't get enough."); |
231 | return AFC_E_MUX_ERROR; | 231 | return AFC_E_MUX_ERROR; |
232 | } else if (recv_len < sizeof(AFCPacket)) { | 232 | } |
233 | |||
234 | if (recv_len < sizeof(AFCPacket)) { | ||
233 | debug_info("Did not even get the AFCPacket header"); | 235 | debug_info("Did not even get the AFCPacket header"); |
234 | return AFC_E_MUX_ERROR; | 236 | return AFC_E_MUX_ERROR; |
235 | } | 237 | } |
@@ -250,14 +252,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t | |||
250 | if (header.this_length < sizeof(AFCPacket)) { | 252 | if (header.this_length < sizeof(AFCPacket)) { |
251 | debug_info("Invalid AFCPacket header received!"); | 253 | debug_info("Invalid AFCPacket header received!"); |
252 | return AFC_E_OP_HEADER_INVALID; | 254 | return AFC_E_OP_HEADER_INVALID; |
253 | } else if ((header.this_length == header.entire_length) | 255 | } |
254 | && header.entire_length == sizeof(AFCPacket)) { | 256 | if ((header.this_length == header.entire_length) |
257 | && header.entire_length == sizeof(AFCPacket)) { | ||
255 | debug_info("Empty AFCPacket received!"); | 258 | debug_info("Empty AFCPacket received!"); |
256 | if (header.operation == AFC_OP_DATA) { | 259 | if (header.operation == AFC_OP_DATA) { |
257 | return AFC_E_SUCCESS; | 260 | return AFC_E_SUCCESS; |
258 | } else { | ||
259 | return AFC_E_IO_ERROR; | ||
260 | } | 261 | } |
262 | return AFC_E_IO_ERROR; | ||
261 | } | 263 | } |
262 | 264 | ||
263 | debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation); | 265 | debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation); |
@@ -273,7 +275,8 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t | |||
273 | free(buf); | 275 | free(buf); |
274 | debug_info("Did not get packet contents!"); | 276 | debug_info("Did not get packet contents!"); |
275 | return AFC_E_NOT_ENOUGH_DATA; | 277 | return AFC_E_NOT_ENOUGH_DATA; |
276 | } else if (recv_len < this_len) { | 278 | } |
279 | if (recv_len < this_len) { | ||
277 | free(buf); | 280 | free(buf); |
278 | debug_info("Could not receive this_len=%d bytes", this_len); | 281 | debug_info("Could not receive this_len=%d bytes", this_len); |
279 | return AFC_E_NOT_ENOUGH_DATA; | 282 | return AFC_E_NOT_ENOUGH_DATA; |
@@ -749,22 +752,23 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t han | |||
749 | if (ret != AFC_E_SUCCESS) { | 752 | if (ret != AFC_E_SUCCESS) { |
750 | afc_unlock(client); | 753 | afc_unlock(client); |
751 | return ret; | 754 | return ret; |
752 | } else if (bytes_loc == 0) { | 755 | } |
756 | if (bytes_loc == 0) { | ||
753 | if (input) | 757 | if (input) |
754 | free(input); | 758 | free(input); |
755 | afc_unlock(client); | 759 | afc_unlock(client); |
756 | *bytes_read = current_count; | 760 | *bytes_read = current_count; |
757 | /* FIXME: check that's actually a success */ | 761 | /* FIXME: check that's actually a success */ |
758 | return ret; | 762 | return ret; |
759 | } else { | ||
760 | if (input) { | ||
761 | debug_info("%d", bytes_loc); | ||
762 | memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); | ||
763 | free(input); | ||
764 | input = NULL; | ||
765 | current_count += (bytes_loc > length) ? length : bytes_loc; | ||
766 | } | ||
767 | } | 763 | } |
764 | if (input) { | ||
765 | debug_info("%d", bytes_loc); | ||
766 | memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); | ||
767 | free(input); | ||
768 | input = NULL; | ||
769 | current_count += (bytes_loc > length) ? length : bytes_loc; | ||
770 | } | ||
771 | |||
768 | afc_unlock(client); | 772 | afc_unlock(client); |
769 | *bytes_read = current_count; | 773 | *bytes_read = current_count; |
770 | return ret; | 774 | return ret; |
diff --git a/src/idevice.c b/src/idevice.c index f64570b..adf47f4 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
@@ -473,7 +473,8 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
473 | new_connection->status = IDEVICE_E_SUCCESS; | 473 | new_connection->status = IDEVICE_E_SUCCESS; |
474 | *connection = new_connection; | 474 | *connection = new_connection; |
475 | return IDEVICE_E_SUCCESS; | 475 | return IDEVICE_E_SUCCESS; |
476 | } else if (device->conn_type == CONNECTION_NETWORK) { | 476 | } |
477 | if (device->conn_type == CONNECTION_NETWORK) { | ||
477 | struct sockaddr_storage saddr_storage; | 478 | struct sockaddr_storage saddr_storage; |
478 | struct sockaddr* saddr = (struct sockaddr*)&saddr_storage; | 479 | struct sockaddr* saddr = (struct sockaddr*)&saddr_storage; |
479 | 480 | ||
@@ -529,10 +530,9 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
529 | *connection = new_connection; | 530 | *connection = new_connection; |
530 | 531 | ||
531 | return IDEVICE_E_SUCCESS; | 532 | return IDEVICE_E_SUCCESS; |
532 | } else { | ||
533 | debug_info("Unknown connection type %d", device->conn_type); | ||
534 | } | 533 | } |
535 | 534 | ||
535 | debug_info("Unknown connection type %d", device->conn_type); | ||
536 | return IDEVICE_E_UNKNOWN_ERROR; | 536 | return IDEVICE_E_UNKNOWN_ERROR; |
537 | } | 537 | } |
538 | 538 | ||
@@ -583,7 +583,8 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection, | |||
583 | return IDEVICE_E_UNKNOWN_ERROR; | 583 | return IDEVICE_E_UNKNOWN_ERROR; |
584 | } | 584 | } |
585 | return IDEVICE_E_SUCCESS; | 585 | return IDEVICE_E_SUCCESS; |
586 | } else if (connection->type == CONNECTION_NETWORK) { | 586 | } |
587 | if (connection->type == CONNECTION_NETWORK) { | ||
587 | int s = socket_send((int)(long)connection->data, (void*)data, len); | 588 | int s = socket_send((int)(long)connection->data, (void*)data, len); |
588 | if (s < 0) { | 589 | if (s < 0) { |
589 | *sent_bytes = 0; | 590 | *sent_bytes = 0; |
@@ -591,9 +592,9 @@ static idevice_error_t internal_connection_send(idevice_connection_t connection, | |||
591 | } | 592 | } |
592 | *sent_bytes = s; | 593 | *sent_bytes = s; |
593 | return IDEVICE_E_SUCCESS; | 594 | return IDEVICE_E_SUCCESS; |
594 | } else { | ||
595 | debug_info("Unknown connection type %d", connection->type); | ||
596 | } | 595 | } |
596 | |||
597 | debug_info("Unknown connection type %d", connection->type); | ||
597 | return IDEVICE_E_UNKNOWN_ERROR; | 598 | return IDEVICE_E_UNKNOWN_ERROR; |
598 | 599 | ||
599 | } | 600 | } |
@@ -638,27 +639,26 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_ | |||
638 | } | 639 | } |
639 | *sent_bytes = sent; | 640 | *sent_bytes = sent; |
640 | return IDEVICE_E_SUCCESS; | 641 | return IDEVICE_E_SUCCESS; |
641 | } else { | 642 | } |
642 | uint32_t sent = 0; | 643 | uint32_t sent = 0; |
643 | while (sent < len) { | 644 | while (sent < len) { |
644 | uint32_t bytes = 0; | 645 | uint32_t bytes = 0; |
645 | int s = internal_connection_send(connection, data+sent, len-sent, &bytes); | 646 | int s = internal_connection_send(connection, data+sent, len-sent, &bytes); |
646 | if (s < 0) { | 647 | if (s < 0) { |
647 | break; | 648 | break; |
648 | } | ||
649 | sent += bytes; | ||
650 | } | ||
651 | debug_info("len %d, sent %d", len, sent); | ||
652 | if (sent < len) { | ||
653 | *sent_bytes = sent; | ||
654 | if (sent == 0) { | ||
655 | return IDEVICE_E_UNKNOWN_ERROR; | ||
656 | } | ||
657 | return IDEVICE_E_NOT_ENOUGH_DATA; | ||
658 | } | 649 | } |
650 | sent += bytes; | ||
651 | } | ||
652 | debug_info("internal_connection_send %d, sent %d", len, sent); | ||
653 | if (sent < len) { | ||
659 | *sent_bytes = sent; | 654 | *sent_bytes = sent; |
660 | return IDEVICE_E_SUCCESS; | 655 | if (sent == 0) { |
656 | return IDEVICE_E_UNKNOWN_ERROR; | ||
657 | } | ||
658 | return IDEVICE_E_NOT_ENOUGH_DATA; | ||
661 | } | 659 | } |
660 | *sent_bytes = sent; | ||
661 | return IDEVICE_E_SUCCESS; | ||
662 | } | 662 | } |
663 | 663 | ||
664 | static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received) | 664 | static inline idevice_error_t socket_recv_to_idevice_error(int conn_error, uint32_t len, uint32_t received) |
@@ -698,7 +698,8 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t | |||
698 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error)); | 698 | debug_info("ERROR: usbmuxd_recv_timeout returned %d (%s)", conn_error, strerror(-conn_error)); |
699 | } | 699 | } |
700 | return error; | 700 | return error; |
701 | } else if (connection->type == CONNECTION_NETWORK) { | 701 | } |
702 | if (connection->type == CONNECTION_NETWORK) { | ||
702 | int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout); | 703 | int res = socket_receive_timeout((int)(long)connection->data, data, len, 0, timeout); |
703 | idevice_error_t error = socket_recv_to_idevice_error(res, 0, 0); | 704 | idevice_error_t error = socket_recv_to_idevice_error(res, 0, 0); |
704 | if (error == IDEVICE_E_SUCCESS) { | 705 | if (error == IDEVICE_E_SUCCESS) { |
@@ -707,9 +708,9 @@ static idevice_error_t internal_connection_receive_timeout(idevice_connection_t | |||
707 | debug_info("ERROR: socket_receive_timeout returned %d (%s)", res, strerror(-res)); | 708 | debug_info("ERROR: socket_receive_timeout returned %d (%s)", res, strerror(-res)); |
708 | } | 709 | } |
709 | return error; | 710 | return error; |
710 | } else { | ||
711 | debug_info("Unknown connection type %d", connection->type); | ||
712 | } | 711 | } |
712 | |||
713 | debug_info("Unknown connection type %d", connection->type); | ||
713 | return IDEVICE_E_UNKNOWN_ERROR; | 714 | return IDEVICE_E_UNKNOWN_ERROR; |
714 | } | 715 | } |
715 | 716 | ||
@@ -793,7 +794,8 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti | |||
793 | return IDEVICE_E_UNKNOWN_ERROR; | 794 | return IDEVICE_E_UNKNOWN_ERROR; |
794 | } | 795 | } |
795 | return IDEVICE_E_SUCCESS; | 796 | return IDEVICE_E_SUCCESS; |
796 | } else if (connection->type == CONNECTION_NETWORK) { | 797 | } |
798 | if (connection->type == CONNECTION_NETWORK) { | ||
797 | int res = socket_receive((int)(long)connection->data, data, len); | 799 | int res = socket_receive((int)(long)connection->data, data, len); |
798 | if (res < 0) { | 800 | if (res < 0) { |
799 | debug_info("ERROR: socket_receive returned %d (%s)", res, strerror(-res)); | 801 | debug_info("ERROR: socket_receive returned %d (%s)", res, strerror(-res)); |
@@ -801,9 +803,9 @@ static idevice_error_t internal_connection_receive(idevice_connection_t connecti | |||
801 | } | 803 | } |
802 | *recv_bytes = (uint32_t)res; | 804 | *recv_bytes = (uint32_t)res; |
803 | return IDEVICE_E_SUCCESS; | 805 | return IDEVICE_E_SUCCESS; |
804 | } else { | ||
805 | debug_info("Unknown connection type %d", connection->type); | ||
806 | } | 806 | } |
807 | |||
808 | debug_info("Unknown connection type %d", connection->type); | ||
807 | return IDEVICE_E_UNKNOWN_ERROR; | 809 | return IDEVICE_E_UNKNOWN_ERROR; |
808 | } | 810 | } |
809 | 811 | ||
@@ -846,17 +848,17 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio | |||
846 | return IDEVICE_E_INVALID_ARG; | 848 | return IDEVICE_E_INVALID_ARG; |
847 | } | 849 | } |
848 | 850 | ||
849 | idevice_error_t result = IDEVICE_E_UNKNOWN_ERROR; | ||
850 | if (connection->type == CONNECTION_USBMUXD) { | 851 | if (connection->type == CONNECTION_USBMUXD) { |
851 | *fd = (int)(long)connection->data; | 852 | *fd = (int)(long)connection->data; |
852 | result = IDEVICE_E_SUCCESS; | 853 | return IDEVICE_E_SUCCESS; |
853 | } else if (connection->type == CONNECTION_NETWORK) { | 854 | } |
855 | if (connection->type == CONNECTION_NETWORK) { | ||
854 | *fd = (int)(long)connection->data; | 856 | *fd = (int)(long)connection->data; |
855 | result = IDEVICE_E_SUCCESS; | 857 | return IDEVICE_E_SUCCESS; |
856 | } else { | ||
857 | debug_info("Unknown connection type %d", connection->type); | ||
858 | } | 858 | } |
859 | return result; | 859 | |
860 | debug_info("Unknown connection type %d", connection->type); | ||
861 | return IDEVICE_E_UNKNOWN_ERROR; | ||
860 | } | 862 | } |
861 | 863 | ||
862 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) | 864 | LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) |
diff --git a/src/lockdown.c b/src/lockdown.c index 25e8c87..d0922dd 100644 --- a/src/lockdown.c +++ b/src/lockdown.c | |||
@@ -163,22 +163,22 @@ lockdownd_error_t lockdown_check_result(plist_t dict, const char *query_match) | |||
163 | 163 | ||
164 | if (plist_get_node_type(query_node) != PLIST_STRING) { | 164 | if (plist_get_node_type(query_node) != PLIST_STRING) { |
165 | return ret; | 165 | return ret; |
166 | } else { | 166 | } |
167 | char *query_value = NULL; | ||
168 | 167 | ||
169 | plist_get_string_val(query_node, &query_value); | 168 | char *query_value = NULL; |
170 | if (!query_value) { | ||
171 | return ret; | ||
172 | } | ||
173 | 169 | ||
174 | if (query_match && (strcmp(query_value, query_match) != 0)) { | 170 | plist_get_string_val(query_node, &query_value); |
175 | free(query_value); | 171 | if (!query_value) { |
176 | return ret; | 172 | return ret; |
177 | } | 173 | } |
178 | 174 | ||
175 | if (query_match && (strcmp(query_value, query_match) != 0)) { | ||
179 | free(query_value); | 176 | free(query_value); |
177 | return ret; | ||
180 | } | 178 | } |
181 | 179 | ||
180 | free(query_value); | ||
181 | |||
182 | plist_t result_node = plist_dict_get_item(dict, "Result"); | 182 | plist_t result_node = plist_dict_get_item(dict, "Result"); |
183 | if (!result_node) { | 183 | if (!result_node) { |
184 | /* iOS 5: the 'Result' key is not present anymore. | 184 | /* iOS 5: the 'Result' key is not present anymore. |
diff --git a/src/misagent.c b/src/misagent.c index d790a05..af925f9 100644 --- a/src/misagent.c +++ b/src/misagent.c | |||
@@ -85,9 +85,8 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code | |||
85 | *status_code = (int)(val & 0xFFFFFFFF); | 85 | *status_code = (int)(val & 0xFFFFFFFF); |
86 | if (*status_code == 0) { | 86 | if (*status_code == 0) { |
87 | return MISAGENT_E_SUCCESS; | 87 | return MISAGENT_E_SUCCESS; |
88 | } else { | ||
89 | return MISAGENT_E_REQUEST_FAILED; | ||
90 | } | 88 | } |
89 | return MISAGENT_E_REQUEST_FAILED; | ||
91 | } | 90 | } |
92 | 91 | ||
93 | LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client) | 92 | LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client) |
diff --git a/src/mobileactivation.c b/src/mobileactivation.c index 2de4333..79c7003 100644 --- a/src/mobileactivation.c +++ b/src/mobileactivation.c | |||
@@ -109,8 +109,6 @@ static plist_t plist_data_from_plist(plist_t plist) | |||
109 | 109 | ||
110 | static mobileactivation_error_t mobileactivation_check_result(plist_t dict, const char *command) | 110 | static mobileactivation_error_t mobileactivation_check_result(plist_t dict, const char *command) |
111 | { | 111 | { |
112 | mobileactivation_error_t ret = MOBILEACTIVATION_E_UNKNOWN_ERROR; | ||
113 | |||
114 | if (!dict || plist_get_node_type(dict) != PLIST_DICT) { | 112 | if (!dict || plist_get_node_type(dict) != PLIST_DICT) { |
115 | return MOBILEACTIVATION_E_PLIST_ERROR; | 113 | return MOBILEACTIVATION_E_PLIST_ERROR; |
116 | } | 114 | } |
@@ -118,14 +116,13 @@ static mobileactivation_error_t mobileactivation_check_result(plist_t dict, cons | |||
118 | plist_t err_node = plist_dict_get_item(dict, "Error"); | 116 | plist_t err_node = plist_dict_get_item(dict, "Error"); |
119 | if (!err_node) { | 117 | if (!err_node) { |
120 | return MOBILEACTIVATION_E_SUCCESS; | 118 | return MOBILEACTIVATION_E_SUCCESS; |
121 | } else { | ||
122 | char *errmsg = NULL; | ||
123 | plist_get_string_val(err_node, &errmsg); | ||
124 | debug_info("ERROR: %s: %s", command, errmsg); | ||
125 | ret = MOBILEACTIVATION_E_REQUEST_FAILED; | ||
126 | free(errmsg); | ||
127 | } | 119 | } |
128 | return ret; | 120 | |
121 | char *errmsg = NULL; | ||
122 | plist_get_string_val(err_node, &errmsg); | ||
123 | debug_info("ERROR: %s: %s", command, errmsg); | ||
124 | free(errmsg); | ||
125 | return MOBILEACTIVATION_E_REQUEST_FAILED; | ||
129 | } | 126 | } |
130 | 127 | ||
131 | static mobileactivation_error_t mobileactivation_send_command_plist(mobileactivation_client_t client, plist_t command, plist_t *result) | 128 | static mobileactivation_error_t mobileactivation_send_command_plist(mobileactivation_client_t client, plist_t command, plist_t *result) |
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c index f4fde95..3726065 100644 --- a/src/mobilebackup2.c +++ b/src/mobilebackup2.c | |||
@@ -240,9 +240,8 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_ | |||
240 | if (sent > 0) { | 240 | if (sent > 0) { |
241 | *bytes = sent; | 241 | *bytes = sent; |
242 | return MOBILEBACKUP2_E_SUCCESS; | 242 | return MOBILEBACKUP2_E_SUCCESS; |
243 | } else { | ||
244 | return MOBILEBACKUP2_E_MUX_ERROR; | ||
245 | } | 243 | } |
244 | return MOBILEBACKUP2_E_MUX_ERROR; | ||
246 | } | 245 | } |
247 | 246 | ||
248 | LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) | 247 | LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes) |
@@ -265,11 +264,11 @@ LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebacku | |||
265 | if (received > 0) { | 264 | if (received > 0) { |
266 | *bytes = received; | 265 | *bytes = received; |
267 | return MOBILEBACKUP2_E_SUCCESS; | 266 | return MOBILEBACKUP2_E_SUCCESS; |
268 | } else if (received == 0) { | 267 | } |
268 | if (received == 0) { | ||
269 | return MOBILEBACKUP2_E_SUCCESS; | 269 | return MOBILEBACKUP2_E_SUCCESS; |
270 | } else { | ||
271 | return MOBILEBACKUP2_E_MUX_ERROR; | ||
272 | } | 270 | } |
271 | return MOBILEBACKUP2_E_MUX_ERROR; | ||
273 | } | 272 | } |
274 | 273 | ||
275 | LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) | 274 | LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version) |
diff --git a/src/preboard.c b/src/preboard.c index b975f0e..4b3b444 100644 --- a/src/preboard.c +++ b/src/preboard.c | |||
@@ -162,7 +162,8 @@ static void* preboard_receive_status_loop_thread(void* arg) | |||
162 | preboard_error_t perr = preboard_receive_with_timeout(data->client, &pl, 1000); | 162 | preboard_error_t perr = preboard_receive_with_timeout(data->client, &pl, 1000); |
163 | if (perr == PREBOARD_E_TIMEOUT) { | 163 | if (perr == PREBOARD_E_TIMEOUT) { |
164 | continue; | 164 | continue; |
165 | } else if (perr == PREBOARD_E_SUCCESS) { | 165 | } |
166 | if (perr == PREBOARD_E_SUCCESS) { | ||
166 | data->cbfunc(pl, data->user_data); | 167 | data->cbfunc(pl, data->user_data); |
167 | } | 168 | } |
168 | plist_free(pl); | 169 | plist_free(pl); |
diff --git a/src/restore.c b/src/restore.c index 4e9d65a..591fd16 100644 --- a/src/restore.c +++ b/src/restore.c | |||
@@ -268,29 +268,27 @@ LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t cli | |||
268 | 268 | ||
269 | LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) | 269 | LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) |
270 | { | 270 | { |
271 | plist_t item; | ||
272 | |||
271 | if (!client || !value || (value && *value)) | 273 | if (!client || !value || (value && *value)) |
272 | return RESTORE_E_INVALID_ARG; | 274 | return RESTORE_E_INVALID_ARG; |
273 | 275 | ||
274 | if (!client->info) | 276 | if (!client->info) |
275 | return RESTORE_E_NOT_ENOUGH_DATA; | 277 | return RESTORE_E_NOT_ENOUGH_DATA; |
276 | 278 | ||
277 | restored_error_t ret = RESTORE_E_SUCCESS; | ||
278 | plist_t item = NULL; | ||
279 | |||
280 | if (!key) { | 279 | if (!key) { |
281 | *value = plist_copy(client->info); | 280 | *value = plist_copy(client->info); |
282 | return RESTORE_E_SUCCESS; | 281 | return RESTORE_E_SUCCESS; |
283 | } else { | ||
284 | item = plist_dict_get_item(client->info, key); | ||
285 | } | 282 | } |
286 | 283 | ||
287 | if (item) { | 284 | item = plist_dict_get_item(client->info, key); |
288 | *value = plist_copy(item); | 285 | if (!item) { |
289 | } else { | 286 | return RESTORE_E_PLIST_ERROR; |
290 | ret = RESTORE_E_PLIST_ERROR; | ||
291 | } | 287 | } |
292 | 288 | ||
293 | return ret; | 289 | *value = plist_copy(item); |
290 | free(item); | ||
291 | return RESTORE_E_SUCCESS; | ||
294 | } | 292 | } |
295 | 293 | ||
296 | LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label) | 294 | LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label) |
diff --git a/src/syslog_relay.c b/src/syslog_relay.c index c137297..ec9eca5 100644 --- a/src/syslog_relay.c +++ b/src/syslog_relay.c | |||
@@ -154,16 +154,15 @@ void *syslog_relay_worker(void *arg) | |||
154 | ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); | 154 | ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); |
155 | if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) { | 155 | if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) { |
156 | continue; | 156 | continue; |
157 | } else if (ret < 0) { | 157 | } |
158 | if (ret < 0) { | ||
158 | debug_info("Connection to syslog relay interrupted"); | 159 | debug_info("Connection to syslog relay interrupted"); |
159 | break; | 160 | break; |
160 | } | 161 | } |
161 | if (srwt->is_raw) { | 162 | if (srwt->is_raw) { |
162 | srwt->cbfunc(c, srwt->user_data); | 163 | srwt->cbfunc(c, srwt->user_data); |
163 | } else { | 164 | } else if (c != 0) { |
164 | if (c != 0) { | 165 | srwt->cbfunc(c, srwt->user_data); |
165 | srwt->cbfunc(c, srwt->user_data); | ||
166 | } | ||
167 | } | 166 | } |
168 | } | 167 | } |
169 | 168 | ||