AP_HAL: Fix TOCTOU in ByteBuffer::peekiovec()

This commit is contained in:
Murilo Belluzzo 2016-07-04 22:31:35 -03:00 committed by Lucas De Marchi
parent 9951b94d40
commit 43d4012884
1 changed files with 5 additions and 3 deletions

View File

@ -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;