diff options
| author | 2008-08-04 11:40:39 +0200 | |
|---|---|---|
| committer | 2008-08-04 22:54:20 -0700 | |
| commit | ab40a42f43dcb273f812706f93d970f95c54bd3f (patch) | |
| tree | 5fdf3b1d9de95386045fdf60941cec3298d37fcc | |
| parent | 9698bafc781befb151a2b485d16cb71321a18aa3 (diff) | |
| download | libplist-ab40a42f43dcb273f812706f93d970f95c54bd3f.tar.gz libplist-ab40a42f43dcb273f812706f93d970f95c54bd3f.tar.bz2 | |
Don't ignore mux_recv errors silently.
Signed-off-by: Matt Colyer <matt@colyer.name>
| -rw-r--r-- | src/AFC.c | 15 | 
1 files changed, 12 insertions, 3 deletions
| @@ -152,7 +152,7 @@ int receive_AFC_data(AFClient *client, char **dump_here) {  	free(buffer);  	if (r_packet->operation == 0x01 && !((client->afc_packet->operation == AFC_DELETE && param1 == 7))) { -		if (debug) printf("Oops? Bad operation code received.\n"); +		if (debug) printf("Oops? Bad operation code received: 0x%0X\n", r_packet->operation);  		if (param1 == 0) {  			if (debug) printf("... false alarm, but still\n");  			return 1; @@ -173,8 +173,17 @@ int receive_AFC_data(AFClient *client, char **dump_here) {  	buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);  	final_buffer = (char*)malloc(sizeof(char) * recv_len);  	while(current_count < recv_len){ -		bytes = mux_recv(client->phone, client->connection, buffer, recv_len); -		if (bytes < 0) break; +		bytes = mux_recv(client->phone, client->connection, buffer, recv_len-current_count); +		if (bytes < 0) +		{ +			if(debug) printf("receive_AFC_data: mux_recv failed: %d\n", bytes); +			break; +		} +		if (bytes > recv_len-current_count) +		{ +			if(debug) printf("receive_AFC_data: mux_recv delivered too much data\n"); +			break; +		}  		memcpy(final_buffer+current_count, buffer, bytes);  		current_count += bytes;  	} | 
