Warn if incoming packet > MAX_PAYLOAD_SIZE and will be truncated

This commit is contained in:
Vasily Evseenko 2023-04-24 14:52:05 +03:00
parent f218f3936c
commit d83bf94e65

View File

@ -326,7 +326,7 @@ void data_source(shared_ptr<Transmitter> &t, vector<int> &rx_fd, int poll_timeou
if (fds[i].revents & POLLIN)
{
uint8_t buf[MAX_PAYLOAD_SIZE];
uint8_t buf[MAX_PAYLOAD_SIZE + 1];
ssize_t rsize;
uint8_t cmsgbuf[CMSG_SPACE(sizeof(uint32_t))];
@ -354,6 +354,12 @@ void data_source(shared_ptr<Transmitter> &t, vector<int> &rx_fd, int poll_timeou
break;
}
if (rsize > MAX_PAYLOAD_SIZE)
{
fprintf(stderr, "Incoming packet size > %d and will be truncated\n", MAX_PAYLOAD_SIZE);
rsize = MAX_PAYLOAD_SIZE;
}
uint32_t cur_rxq_overflow = extract_rxq_overflow(&msghdr);
if (cur_rxq_overflow != rxq_overflow)
{