Skip to content

Commit

Permalink
patch buffer overflow in client for payloads greater than one packet
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeToogo committed Oct 17, 2021
1 parent 97d3b6a commit 50566a1
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions client/c/client.c
Expand Up @@ -339,20 +339,27 @@ uint8_t ff_client_send_request(struct ff_client_config *config, struct ff_client

for (uint16_t i = 0; i < packets_count; i++)
{
do
ff_log(
FF_INFO, "sending packet %d byte range [%d, %d]",
i, 0, (int)packets[i].length
);
chunk_length = sendto(
sockfd,
packets[i].value,
(int)packets[i].length,
0,
res->ai_addr,
res->ai_addrlen
);

if (chunk_length <= 0)
{
ff_log(FF_INFO, "test: %d", packets_count);
chunk_length = sendto(sockfd, packets[i].value + sent_length, packets[i].length, 0, res->ai_addr, res->ai_addrlen);

if (chunk_length <= 0)
{
printf("errno: %d\n", errno);
ff_log(FF_FATAL, "Failed to send UDP datagrams during byte range %d - %hu", sent_length, packets[i].length);
goto error;
}

sent_length += chunk_length;
} while (sent_length < packets[i].length);
printf("errno: %d\n", errno);
ff_log(FF_FATAL, "Failed to send UDP datagrams during byte range %d - %hu", 0, packets[i].length);
goto error;
}

sent_length += chunk_length;
}

ff_log(FF_DEBUG, "Finished sending %d bytes", sent_length);
Expand Down

0 comments on commit 50566a1

Please sign in to comment.