diff options
Diffstat (limited to 'src')
| -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) { | |||
| 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 | } |
