Browse Source

AP_HAL: Fix TOCTOU in ByteBuffer::peekiovec()

mission-4.1.18
Murilo Belluzzo 9 years ago committed by Lucas De Marchi
parent
commit
43d4012884
  1. 8
      libraries/AP_HAL/utility/RingBuffer.cpp

8
libraries/AP_HAL/utility/RingBuffer.cpp

@ -98,13 +98,15 @@ bool ByteBuffer::advance(uint32_t n) @@ -98,13 +98,15 @@ bool ByteBuffer::advance(uint32_t n)
uint8_t ByteBuffer::peekiovec(ByteBuffer::IoVec iovec[2], uint32_t len)
{
if (len > available()) {
len = available();
uint32_t n = available();
if (len > n) {
len = n;
}
if (len == 0) {
return 0;
}
uint32_t n;
auto b = readptr(n);
if (n > len) {
n = len;

Loading…
Cancel
Save