diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-03-12 20:16:38 +0000 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2020-03-31 21:14:35 +0800 |
commit | a43790f2f6155597e120409f467a3d41de3cfb53 (patch) | |
tree | a5aa64318813bbfaeef494b0156d18b37b394b6d /hw/net/trace-events | |
parent | baba731bc6e7920ec2dca7d449b6bf7d42e4901f (diff) |
hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive()
The i82596_receive() function attempts to pass the guest a buffer
which is effectively the concatenation of the data it is passed and a
4 byte CRC value. However, rather than implementing this as "write
the data; then write the CRC" it instead bumps the length value of
the data by 4, and writes 4 extra bytes from beyond the end of the
buffer, which it then overwrites with the CRC. It also assumed that
we could always fit all four bytes of the CRC into the final receive
buffer, which might not be true if the CRC needs to be split over two
receive buffers.
Calculate separately how many bytes we need to transfer into the
guest's receive buffer from the source buffer, and how many we need
to transfer from the CRC work.
We add a count 'bufsz' of the number of bytes left in the source
buffer, which we use purely to assert() that we don't overrun.
Spotted by Coverity (CID 1419396) for the specific case when we end
up using a local array as the source buffer.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/trace-events')
0 files changed, 0 insertions, 0 deletions