Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoming Packet Validation #78

Merged
merged 3 commits into from
Sep 5, 2024
Merged

Incoming Packet Validation #78

merged 3 commits into from
Sep 5, 2024

Conversation

kralverde
Copy link
Contributor

Got this error after leaving the server on a public ip:

thread 'main' panicked at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes_mut.rs:394:9:
split_to out of bounds: 3 <= 2
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/panicking.rs:72:14
   2: bytes::bytes_mut::BytesMut::split_to
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes_mut.rs:394:9
   3: <bytes::bytes_mut::BytesMut as bytes::buf::buf_impl::Buf>::copy_to_bytes
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes_mut.rs:1165:9
   4: pumpkin_protocol::bytebuf::ByteBuffer::get_string_len
             at ./pumpkin-protocol/src/bytebuf/mod.rs:87:20
   5: <pumpkin_protocol::server::handshake::SHandShake as pumpkin_protocol::ServerPacket>::read
             at ./pumpkin-protocol/src/server/handshake/mod.rs:20:29
   6: pumpkin::client::Client::handle_packet::{{closure}}
             at ./pumpkin/src/client/mod.rs:172:51
   7: pumpkin::client::Client::process_packets::{{closure}}
             at ./pumpkin/src/client/mod.rs:150:59
   8: pumpkin::main::{{closure}}
             at ./pumpkin/src/main.rs:186:69
   9: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/future/future.rs:123:9
  10: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/park.rs:281:63
  11: tokio::runtime::coop::with_budget
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/coop.rs:107:5
  12: tokio::runtime::coop::budget
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/coop.rs:73:5
  13: tokio::runtime::park::CachedParkThread::block_on
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/park.rs:281:31
  14: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/context/blocking.rs:66:9
  15: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/scheduler/multi_thread/mod.rs:87:13
  16: tokio::runtime::context::runtime::enter_runtime
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/context/runtime.rs:65:16
  17: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/scheduler/multi_thread/mod.rs:86:9
  18: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/runtime.rs:363:45
  19: tokio::runtime::runtime::Runtime::block_on
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.39.2/src/runtime/runtime.rs:333:13
  20: pumpkin::main
             at ./pumpkin/src/main.rs:58:5
  21: core::ops::function::FnOnce::call_once
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This PR hopes to prevent these panics in the case of bad packets, instead propagating errors up

@Snowiiii
Copy link
Member

Snowiiii commented Sep 5, 2024

Hey, Great Job this was on my todo list aswell. I wonder since when this error is there?. I never encountered it myself. Is this only with Public IP or also with normal

@kralverde
Copy link
Contributor Author

This was public, someone sending bad packets

@Snowiiii
Copy link
Member

Snowiiii commented Sep 5, 2024

This was public, someone sending bad packets

Ah. You mean just random bad packets?. Okay i get it. I tought there would be an error when doing normal client behavoiur

@Snowiiii
Copy link
Member

Snowiiii commented Sep 5, 2024

Thanks you @kralverde

@Snowiiii Snowiiii merged commit e3c392c into Pumpkin-MC:master Sep 5, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants