mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-05 13:57:39 +03:00
fix double reserve of mask bytes. (#162)
This commit is contained in:
parent
ce80c79091
commit
8cbd8758a5
1 changed files with 5 additions and 5 deletions
|
@ -175,14 +175,14 @@ impl Parser {
|
||||||
};
|
};
|
||||||
|
|
||||||
if payload_len < 126 {
|
if payload_len < 126 {
|
||||||
dst.reserve(p_len + 2 + if mask { 4 } else { 0 });
|
dst.reserve(p_len + 2);
|
||||||
dst.extend_from_slice(&[one, two | payload_len as u8]);
|
dst.extend_from_slice(&[one, two | payload_len as u8]);
|
||||||
} else if payload_len <= 65_535 {
|
} else if payload_len <= 65_535 {
|
||||||
dst.reserve(p_len + 4 + if mask { 4 } else { 0 });
|
dst.reserve(p_len + 4);
|
||||||
dst.extend_from_slice(&[one, two | 126]);
|
dst.extend_from_slice(&[one, two | 126]);
|
||||||
dst.put_u16(payload_len as u16);
|
dst.put_u16(payload_len as u16);
|
||||||
} else {
|
} else {
|
||||||
dst.reserve(p_len + 10 + if mask { 4 } else { 0 });
|
dst.reserve(p_len + 10);
|
||||||
dst.extend_from_slice(&[one, two | 127]);
|
dst.extend_from_slice(&[one, two | 127]);
|
||||||
dst.put_u64(payload_len as u64);
|
dst.put_u64(payload_len as u64);
|
||||||
};
|
};
|
||||||
|
@ -190,11 +190,11 @@ impl Parser {
|
||||||
if mask {
|
if mask {
|
||||||
let mask: u32 = WyRand::new().generate();
|
let mask: u32 = WyRand::new().generate();
|
||||||
dst.put_u32_le(mask);
|
dst.put_u32_le(mask);
|
||||||
dst.extend_from_slice(payload.as_ref());
|
dst.extend_from_slice(payload);
|
||||||
let pos = dst.len() - payload_len;
|
let pos = dst.len() - payload_len;
|
||||||
apply_mask(&mut dst[pos..], mask);
|
apply_mask(&mut dst[pos..], mask);
|
||||||
} else {
|
} else {
|
||||||
dst.extend_from_slice(payload.as_ref());
|
dst.extend_from_slice(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue