summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Aumueller2008-08-04 11:40:39 +0200
committerGravatar Matt Colyer2008-08-04 22:54:20 -0700
commitab40a42f43dcb273f812706f93d970f95c54bd3f (patch)
tree5fdf3b1d9de95386045fdf60941cec3298d37fcc
parent9698bafc781befb151a2b485d16cb71321a18aa3 (diff)
downloadlibimobiledevice-ab40a42f43dcb273f812706f93d970f95c54bd3f.tar.gz
libimobiledevice-ab40a42f43dcb273f812706f93d970f95c54bd3f.tar.bz2
Don't ignore mux_recv errors silently.
Signed-off-by: Matt Colyer <matt@colyer.name>
-rw-r--r--src/AFC.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 052213f..675d127 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -152,7 +152,7 @@ int receive_AFC_data(AFClient *client, char **dump_here) {
152 free(buffer); 152 free(buffer);
153 153
154 if (r_packet->operation == 0x01 && !((client->afc_packet->operation == AFC_DELETE && param1 == 7))) { 154 if (r_packet->operation == 0x01 && !((client->afc_packet->operation == AFC_DELETE && param1 == 7))) {
155 if (debug) printf("Oops? Bad operation code received.\n"); 155 if (debug) printf("Oops? Bad operation code received: 0x%0X\n", r_packet->operation);
156 if (param1 == 0) { 156 if (param1 == 0) {
157 if (debug) printf("... false alarm, but still\n"); 157 if (debug) printf("... false alarm, but still\n");
158 return 1; 158 return 1;
@@ -173,8 +173,17 @@ int receive_AFC_data(AFClient *client, char **dump_here) {
173 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE); 173 buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);
174 final_buffer = (char*)malloc(sizeof(char) * recv_len); 174 final_buffer = (char*)malloc(sizeof(char) * recv_len);
175 while(current_count < recv_len){ 175 while(current_count < recv_len){
176 bytes = mux_recv(client->phone, client->connection, buffer, recv_len); 176 bytes = mux_recv(client->phone, client->connection, buffer, recv_len-current_count);
177 if (bytes < 0) break; 177 if (bytes < 0)
178 {
179 if(debug) printf("receive_AFC_data: mux_recv failed: %d\n", bytes);
180 break;
181 }
182 if (bytes > recv_len-current_count)
183 {
184 if(debug) printf("receive_AFC_data: mux_recv delivered too much data\n");
185 break;
186 }
178 memcpy(final_buffer+current_count, buffer, bytes); 187 memcpy(final_buffer+current_count, buffer, bytes);
179 current_count += bytes; 188 current_count += bytes;
180 } 189 }