AtherEnergy / rumqtt

Pure rust mqtt cilent
The Unlicense
202 stars 71 forks source link

Panic with large keep-alive #88

Closed gabisurita closed 6 years ago

gabisurita commented 6 years ago

Keep alives larger than 327 will lead to a multiply overflow. I think the problem is a missing cast before * 1000 on the following line:

https://github.com/AtherEnergy/rumqtt/blob/857404403f3f4494c4636b041c878b7d85cff083/src/connection.rs#L688

Here is the traceback:

thread '<unnamed>' panicked at 'attempt to multiply with overflow', /Users/gusurita/.cargo/registry/src/github.com-1ecc6299db9ec823/rumqtt-0.10.1/src/connection.rs:688:58
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: sentry::integrations::panic::register_panic_handler::{{closure}}
             at /Users/gusurita/.cargo/registry/src/github.com-1ecc6299db9ec823/sentry-0.6.1/src/integrations/panic.rs:74
   5: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at libstd/panicking.rs:515
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   7: std::panicking::try::do_call
             at libstd/panicking.rs:337
   8: <T as core::any::Any>::get_type_id
             at libcore/panicking.rs:92
   9: <T as core::any::Any>::get_type_id
             at libcore/panicking.rs:53
  10: rumqtt::connection::Connection::ping
             at /Users/gusurita/.cargo/registry/src/github.com-1ecc6299db9ec823/rumqtt-0.10.1/src/connection.rs:688
  11: rumqtt::connection::Connection::run
             at /Users/gusurita/.cargo/registry/src/github.com-1ecc6299db9ec823/rumqtt-0.10.1/src/connection.rs:194
  12: rumqtt::client::MqttClient::start::{{closure}}
             at /Users/gusurita/.cargo/registry/src/github.com-1ecc6299db9ec823/rumqtt-0.10.1/src/client.rs:45
  13: <core::alloc::CollectionAllocErr as core::convert::From<core::alloc::AllocErr>>::from
             at /Users/travis/build/rust-lang/rust/src/libstd/sys_common/backtrace.rs:136
  14: std::io::Initializer::zeroing
             at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:409
  15: <core::str::pattern::RejectAndMatch as core::str::pattern::TwoWayStrategy>::rejecting
             at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:313
  16: <core::str::pattern::StrSearcher<'a, 'b> as core::str::pattern::Searcher<'a>>::haystack
             at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:310
  17: panic_unwind::dwarf::eh::read_encoded_pointer
             at libpanic_unwind/lib.rs:105
  18: <core::str::pattern::StrSearcher<'a, 'b> as core::str::pattern::Searcher<'a>>::haystack
             at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:289
  19: std::net::tcp::TcpStream
             at /Users/travis/build/rust-lang/rust/src/libstd/panic.rs:392
  20: std::io::Initializer::zeroing
             at /Users/travis/build/rust-lang/rust/src/libstd/thread/mod.rs:408
  21: <usize as core::iter::range::Step>::steps_between
             at /Users/travis/build/rust-lang/rust/src/liballoc/boxed.rs:640
  22: std::sys_common::thread::start_thread
             at /Users/travis/build/rust-lang/rust/src/liballoc/boxed.rs:650
             at libstd/sys_common/thread.rs:24
  23: std::sys::unix::thread::Thread::new::thread_start
             at libstd/sys/unix/thread.rs:90
  24: _pthread_body
  25: _pthread_start