]> begriffs open source - freertos/commit
Fix prvWriteMessageToBuffer on big endian (#391)
authorArchit Gupta <71798289+archigup@users.noreply.github.com>
Sat, 16 Oct 2021 23:36:44 +0000 (16:36 -0700)
committerGitHub <noreply@github.com>
Sat, 16 Oct 2021 23:36:44 +0000 (16:36 -0700)
commitd649a771282b2d23c3ab212cede3ad32d841747d
tree8bfe1fd24b43f97b32dbae170c4e34b175dab4a2
parent06fb777e430aae9bb19745f1e4f8c299f4bb69f3
Fix prvWriteMessageToBuffer on big endian (#391)

prvWriteMessageToBuffer wrote the first sbBYTES_TO_STORE_MESSAGE_LENGTH
bytes of the size_t-typed length to the buffer as the data length. While
this functions on little endian, it copies the wrong bytes on big
endian. This fix converts the length to configMESSAGE_BUFFER_LENGTH_TYPE
first, and then copies the exact amount, thus fixing the issue.
Additionally it adds an assert to verify the size is not greater than
the max value of configMESSAGE_BUFFER_LENGTH_TYPE; previously this would
truncate silently.

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
stream_buffer.c