mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 09:15:14 +01:00
tun: freebsd: avoid OOB writes
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
0687dc06c8
commit
3625f8d284
@ -8,6 +8,7 @@ package tun
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
@ -347,7 +348,13 @@ func (tun *NativeTun) Read(buff []byte, offset int) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Write(buf []byte, offset int) (int, error) {
|
func (tun *NativeTun) Write(buf []byte, offset int) (int, error) {
|
||||||
|
if offset < 4 {
|
||||||
|
return 0, io.ErrShortBuffer
|
||||||
|
}
|
||||||
buf = buf[offset-4:]
|
buf = buf[offset-4:]
|
||||||
|
if len(buf) < 5 {
|
||||||
|
return 0, io.ErrShortBuffer
|
||||||
|
}
|
||||||
buf[0] = 0x00
|
buf[0] = 0x00
|
||||||
buf[1] = 0x00
|
buf[1] = 0x00
|
||||||
buf[2] = 0x00
|
buf[2] = 0x00
|
||||||
|
Loading…
Reference in New Issue
Block a user