summaryrefslogtreecommitdiffstats
path: root/src/afc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afc.c')
-rw-r--r--src/afc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/afc.c b/src/afc.c
index e2e5ba1..05f5353 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -290,7 +290,7 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t
290 } 290 }
291 291
292 /* then, read the attached packet */ 292 /* then, read the attached packet */
293 if (header.this_length < sizeof(AFCPacket)) { 293 if (header.this_length < sizeof(AFCPacket) || header.entire_length < sizeof(AFCPacket) || header.entire_length > UINT32_MAX || header.this_length > header.entire_length) {
294 debug_info("Invalid AFCPacket header received!"); 294 debug_info("Invalid AFCPacket header received!");
295 return AFC_E_OP_HEADER_INVALID; 295 return AFC_E_OP_HEADER_INVALID;
296 } 296 }
@@ -309,6 +309,10 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t
309 this_len = (uint32_t)header.this_length - sizeof(AFCPacket); 309 this_len = (uint32_t)header.this_length - sizeof(AFCPacket);
310 310
311 buf = (char*)malloc(entire_len); 311 buf = (char*)malloc(entire_len);
312 if (!buf) {
313 debug_info("Failed to allocate %u bytes for packet buffer", entire_len);
314 return AFC_E_NO_MEM;
315 }
312 if (this_len > 0) { 316 if (this_len > 0) {
313 recv_len = 0; 317 recv_len = 0;
314 err = service_to_afc_error(service_receive(client->parent, buf, this_len, &recv_len)); 318 err = service_to_afc_error(service_receive(client->parent, buf, this_len, &recv_len));