mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-22 23:56:01 +00:00
fix a buffer corruption
This commit is contained in:
+9
-5
@@ -1265,11 +1265,15 @@ char * ss_decrypt_all(int buf_size, char *ciphertext, ssize_t *len, int method,
|
||||
}
|
||||
|
||||
if (auth || (plaintext[0] & ONETIMEAUTH_FLAG)) {
|
||||
char hash[ONETIMEAUTH_BYTES];
|
||||
memcpy(hash, plaintext + p_len - ONETIMEAUTH_BYTES, ONETIMEAUTH_BYTES);
|
||||
ret = !ss_onetimeauth_verify(hash, plaintext, p_len - ONETIMEAUTH_BYTES, iv);
|
||||
if (ret) {
|
||||
p_len -= ONETIMEAUTH_BYTES;
|
||||
if (p_len > ONETIMEAUTH_BYTES) {
|
||||
char hash[ONETIMEAUTH_BYTES];
|
||||
memcpy(hash, plaintext + p_len - ONETIMEAUTH_BYTES, ONETIMEAUTH_BYTES);
|
||||
ret = !ss_onetimeauth_verify(hash, plaintext, p_len - ONETIMEAUTH_BYTES, iv);
|
||||
if (ret) {
|
||||
p_len -= ONETIMEAUTH_BYTES;
|
||||
}
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user