1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check if mut function arg is declared as mut (#5579)

This commit is contained in:
Uwe Krüger
2020-06-30 14:19:22 +02:00
committed by GitHub
parent 8d7eccb8e1
commit 8a46911725
13 changed files with 88 additions and 31 deletions

View File

@@ -54,7 +54,7 @@ pub fn (x &AesCbc) encrypt_blocks(mut dst []byte, src_ []byte) {
if dst.len < src.len {
panic('crypto.cipher: output smaller than input')
}
if subtle.inexact_overlap((*dst)[..src.len], src) {
if subtle.inexact_overlap((*dst)[..src.len], src_) {
panic('crypto.cipher: invalid buffer overlap')
}
@@ -63,7 +63,7 @@ pub fn (x &AesCbc) encrypt_blocks(mut dst []byte, src_ []byte) {
for src.len > 0 {
// Write the xor to dst, then encrypt in place.
cipher.xor_bytes(mut (*dst)[..x.block_size], src[..x.block_size], iv)
x.b.encrypt((*dst)[..x.block_size], (*dst)[..x.block_size])
x.b.encrypt(mut (*dst)[..x.block_size], mut (*dst)[..x.block_size])
// Move to the next block with this block as the next iv.
iv = (*dst)[..x.block_size]
@@ -104,7 +104,7 @@ pub fn (mut x AesCbc) decrypt_blocks(mut dst []byte, src []byte) {
// Loop over all but the first block.
for start > 0 {
x.b.decrypt((*dst).slice(start, end), src.slice(start, end))
x.b.decrypt(mut (*dst).slice(start, end), mut src.slice(start, end))
cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), src.slice(prev, start))
end = start
@@ -113,7 +113,7 @@ pub fn (mut x AesCbc) decrypt_blocks(mut dst []byte, src []byte) {
}
// The first block is special because it uses the saved iv.
x.b.decrypt((*dst).slice(start, end), src.slice(start, end))
x.b.decrypt(mut (*dst).slice(start, end), mut src.slice(start, end))
cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), x.iv)