On Sunday 31 May 2015 13:35:56 Sven Eckelmann wrote:
It is checked when data is send by checking if the data would fit inside the outgoing UDP packet. But it is not checked if the data would fit after the sending was done. This doesn't have to be true just from the restrictions which can be seen in this function. So just check if the data and its headers would now fit in outgoing buffer before copying the data to the output buffer.
This is not a problem by itself because the data + header in the dataset cannot be larger than (MAX_PAYLOAD - sizeof(struct alfred_push_data_v0)).
Alternative commit message:
The sending code is automatically transmitting a packet when the next data block would not fit inside the outgoing, aggregated UDP packet. But the code does not check whether the data would then fit inside the new, complete empty push_data packet. It is currently no problem because alfred has the restriction that a dataset never stores a buffer larger than (MAX_PAYLOAD - sizeof(struct alfred_push_data_v0) - sizeof(struct alfred_data)). Therefore, the length check for the empty push_data packet + dataset buffer would never fail.
Nonetheless, make this check explicit to avoid problems when the receiving code is changed or the sending code gets the ability to limit the size of outgoing UDP packets.