1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-10 14:26:26 -05:00

iv check should proceed after decryption

This commit is contained in:
Shelikhoo 2021-03-05 08:48:17 +00:00
parent 6b542f59a9
commit 7f5bc447d9
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -61,12 +61,6 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
iv = append([]byte(nil), buffer.BytesTo(ivLen)...)
}
if ivError := account.CheckIV(iv); ivError != nil {
readSizeRemain -= int(buffer.Len())
DrainConnN(reader, readSizeRemain)
return nil, nil, newError("failed iv check").Base(ivError)
}
r, err := account.Cipher.NewDecryptionReader(account.Key, iv, reader)
if err != nil {
readSizeRemain -= int(buffer.Len())
@ -100,6 +94,12 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
return nil, nil, newError("invalid remote address.")
}
if ivError := account.CheckIV(iv); ivError != nil {
readSizeRemain -= int(buffer.Len())
DrainConnN(reader, readSizeRemain)
return nil, nil, newError("failed iv check").Base(ivError)
}
return request, br, nil
}