mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2025-07-28 16:02:50 +02:00
more refined boundary checks
Signed-off-by: Mark Puha <marko10@inf.elte.hu>
This commit is contained in:
parent
e6fdad372b
commit
84cb7b4b61
1 changed files with 18 additions and 7 deletions
|
@ -4,6 +4,9 @@ import "log"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if IsAdvancedSecurityOn() {
|
if IsAdvancedSecurityOn() {
|
||||||
|
if JunkPacketCount < 0 {
|
||||||
|
log.Fatalf("JunkPacketCount should be non negative")
|
||||||
|
}
|
||||||
if JunkPacketMaxSize <= JunkPacketMinSize {
|
if JunkPacketMaxSize <= JunkPacketMinSize {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"MaxSize: %d; should be greater than MinSize: %d",
|
"MaxSize: %d; should be greater than MinSize: %d",
|
||||||
|
@ -11,31 +14,39 @@ func init() {
|
||||||
JunkPacketMinSize,
|
JunkPacketMinSize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if JunkPacketCount < 0 {
|
|
||||||
log.Fatalf("JunkPacketCount should be non negative")
|
|
||||||
}
|
|
||||||
const MaxSegmentSize = 2048 - 32
|
const MaxSegmentSize = 2048 - 32
|
||||||
|
if JunkPacketMaxSize >= MaxSegmentSize {
|
||||||
|
log.Fatalf(
|
||||||
|
"JunkPacketMaxSize: %d; should be smaller than maxSegmentSize: %d",
|
||||||
|
JunkPacketMaxSize,
|
||||||
|
MaxSegmentSize,
|
||||||
|
)
|
||||||
|
}
|
||||||
if 148+InitPacketJunkSize >= MaxSegmentSize {
|
if 148+InitPacketJunkSize >= MaxSegmentSize {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"init packets should be smaller than maxSegmentSize: %d",
|
"init header size(148) + junkSize:%d; should be smaller than maxSegmentSize: %d",
|
||||||
|
InitPacketJunkSize,
|
||||||
MaxSegmentSize,
|
MaxSegmentSize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if 92+ResponsePacketJunkSize >= MaxSegmentSize {
|
if 92+ResponsePacketJunkSize >= MaxSegmentSize {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"response packets should be smaller than maxSegmentSize: %d",
|
"response header size(92) + junkSize:%d; should be smaller than maxSegmentSize: %d",
|
||||||
|
ResponsePacketJunkSize,
|
||||||
MaxSegmentSize,
|
MaxSegmentSize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if 64+UnderLoadPacketJunkSize >= MaxSegmentSize {
|
if 64+UnderLoadPacketJunkSize >= MaxSegmentSize {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"underload packets should be smaller than maxSegmentSize: %d",
|
"underload packet size(64) + junkSize:%d; should be smaller than maxSegmentSize: %d",
|
||||||
|
UnderLoadPacketJunkSize,
|
||||||
MaxSegmentSize,
|
MaxSegmentSize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if 32+TransportPacketJunkSize >= MaxSegmentSize {
|
if 32+TransportPacketJunkSize >= MaxSegmentSize {
|
||||||
log.Fatalf(
|
log.Fatalf(
|
||||||
"transport packets should be smaller than maxSegmentSize: %d",
|
"transport packet size(32) + junkSize:%d should be smaller than maxSegmentSize: %d",
|
||||||
|
TransportPacketJunkSize,
|
||||||
MaxSegmentSize,
|
MaxSegmentSize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue