diff options
| author | mat <github@matdoes.dev> | 2022-10-07 23:56:23 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-07 23:56:23 -0500 |
| commit | 6f6289376a0d9ffe7e58506824e37f6b380961c3 (patch) | |
| tree | 97956fc560b338fbef630f0d0617a248e0e8b336 /azalea-nbt/src | |
| parent | e9d8d0357ee63cce321e177bf19a8974699894ee (diff) | |
| download | azalea-drasl-6f6289376a0d9ffe7e58506824e37f6b380961c3.tar.xz | |
fix errors with rewritten packet reading
i forgot i never tested it before LMAO
Diffstat (limited to 'azalea-nbt/src')
| -rwxr-xr-x | azalea-nbt/src/decode.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs index 8a1dfab5..a811bb1f 100755 --- a/azalea-nbt/src/decode.rs +++ b/azalea-nbt/src/decode.rs @@ -9,7 +9,7 @@ use std::io::{BufRead, Read}; #[inline] fn read_bytes<'a>(buf: &'a mut Cursor<&[u8]>, length: usize) -> Result<&'a [u8], Error> { - if length > buf.get_ref().len() { + if length > (buf.get_ref().len() - buf.position() as usize) { return Err(Error::UnexpectedEof); } let initial_position = buf.position() as usize; @@ -95,7 +95,7 @@ impl Tag { // integers. 11 => { let length = stream.read_u32::<BE>()? as usize; - if length * 4 > stream.get_ref().len() { + if length * 4 > (stream.get_ref().len() - stream.position() as usize) { return Err(Error::UnexpectedEof); } let mut ints = Vec::with_capacity(length as usize); @@ -108,7 +108,7 @@ impl Tag { // integer (thus 4 bytes) and indicates the number of 8 byte longs. 12 => { let length = stream.read_u32::<BE>()? as usize; - if length * 8 > stream.get_ref().len() { + if length * 8 > (stream.get_ref().len() - stream.position() as usize) { return Err(Error::UnexpectedEof); } let mut longs = Vec::with_capacity(length as usize); |
