diff --git a/proxy/vmess/command/accounts.go b/proxy/vmess/command/accounts.go index 5ba3996f4..b01c78770 100644 --- a/proxy/vmess/command/accounts.go +++ b/proxy/vmess/command/accounts.go @@ -80,7 +80,7 @@ func (this *SwitchAccount) Unmarshal(data []byte) error { } this.AlterIds = serial.ParseUint16(data[alterIdStart : alterIdStart+2]) levelStart := alterIdStart + 2 - if len(data) < levelStart { + if len(data) < levelStart+1 { return transport.CorruptedPacket } this.Level = vmess.UserLevel(data[levelStart]) diff --git a/proxy/vmess/command/accounts_fuzz.go b/proxy/vmess/command/testing/fuzzing/accounts_fuzz.go similarity index 64% rename from proxy/vmess/command/accounts_fuzz.go rename to proxy/vmess/command/testing/fuzzing/accounts_fuzz.go index 4e1c33117..325d2501e 100644 --- a/proxy/vmess/command/accounts_fuzz.go +++ b/proxy/vmess/command/testing/fuzzing/accounts_fuzz.go @@ -1,6 +1,10 @@ // +build gofuzz -package command +package fuzzing + +import ( + . "github.com/v2ray/v2ray-core/proxy/vmess/command" +) func Fuzz(data []byte) int { cmd := new(SwitchAccount) diff --git a/proxy/vmess/command/testing/fuzzing/data/empty_host.corpus b/proxy/vmess/command/testing/fuzzing/data/empty_host.corpus new file mode 100644 index 000000000..340adecd2 Binary files /dev/null and b/proxy/vmess/command/testing/fuzzing/data/empty_host.corpus differ