mirror of https://github.com/ArduPilot/ardupilot
AP_HAL: Fix TOCTOU in ByteBuffer::peekiovec()
This commit is contained in:
parent
9951b94d40
commit
43d4012884
|
@ -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…
Reference in New Issue