mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-11 02:18:29 -04:00
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)
|
uint8_t ByteBuffer::peekiovec(ByteBuffer::IoVec iovec[2], uint32_t len)
|
||||||
{
|
{
|
||||||
if (len > available()) {
|
uint32_t n = available();
|
||||||
len = available();
|
|
||||||
|
if (len > n) {
|
||||||
|
len = n;
|
||||||
}
|
}
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint32_t n;
|
|
||||||
auto b = readptr(n);
|
auto b = readptr(n);
|
||||||
if (n > len) {
|
if (n > len) {
|
||||||
n = len;
|
n = len;
|
||||||
|
Loading…
Reference in New Issue
Block a user