crosvm/p9
Chirantan Ekbote f2fb37e669 p9: Fix unsafe block in read function
We calculate the size of the buffer to allocate for a read message by
finding the minimum of the requested size and the number of bytes left
in the response message buffer.

However, we then turned around and used an unsafe block to set the
length of the allocated buffer to the requested size rather than the
calculated size.  This could lead to memory corruption if the file we
were trying to read had enough bytes to fill up the whole buffer and the
requested size was larger than the max message size.

Replace both unsafe blocks with a resize function instead.  The
compiler is smart enough to turn this into a memset and
zero-initializing a few KB of memory is not that expensive.

BUG=chromium:703939
TEST=none

Change-Id: Ia9911d4176322bc9af0753541bd29d7a4723503b
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1110479
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-06-21 19:56:34 -07:00
..
src p9: Fix unsafe block in read function 2018-06-21 19:56:34 -07:00
wire_format_derive Add low-level p9 protocol implementation 2018-05-22 21:56:58 -07:00
Cargo.toml p9: Add server implementation 2018-06-15 10:56:39 -07:00