aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-10-07 23:56:23 -0500
committermat <github@matdoes.dev>2022-10-07 23:56:23 -0500
commit6f6289376a0d9ffe7e58506824e37f6b380961c3 (patch)
tree97956fc560b338fbef630f0d0617a248e0e8b336 /azalea-nbt/src
parente9d8d0357ee63cce321e177bf19a8974699894ee (diff)
downloadazalea-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-xazalea-nbt/src/decode.rs6
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);