inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

unimplemented crash in iber #1

Closed clux closed 7 years ago

clux commented 7 years ago

Hey, I'm trying out this library and while I may have gotten some of my internal company ldap details slightly wrong, it's quite hard to debug what's going wrong atm:

extern crate ldap3;
use ldap3::{LdapConn, Scope, SearchEntry};

fn main() {
    let ldap = LdapConn::new("ldaps://myldaphost.com").unwrap();

    let (result_set, result, _controls) = ldap.search(
        "dc=some,dc=thing,dc=com", // search base
        Scope::Subtree,
        "sAMAccountName=ealbrigt", // search filter
        vec![] as Vec<&str>
    ).unwrap();
}

Produces the following crash:

thread 'main' panicked at 'not yet implemented', /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/lber-0.1.2/src/parse.rs:80
stack backtrace:
   0:     0x558bc32d0d23 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h0c49f46a3545f908
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x558bc32ccdf4 - std::sys_common::backtrace::_print::hcef39a9816714c4c
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x558bc32d2bb7 - std::panicking::default_hook::{{closure}}::h7c3c94835e02f846
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x558bc32d273b - std::panicking::default_hook::h0bf7bc3112fb107d
                               at /checkout/src/libstd/panicking.rs:371
   4:     0x558bc32d308b - std::panicking::rust_panic_with_hook::ha27630c950090fec
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x558bc322a668 - std::panicking::begin_panic::hb8f8e0f66c5cbc9b
                               at /checkout/src/libstd/panicking.rs:511
   6:     0x558bc32359b9 - lber::parse::parse_uint::h6ac9ab0bbe171e54
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/lber-0.1.2/src/parse.rs:80
   7:     0x558bc323fe15 - lber::parse::parse_length::h023937b9d2f5edef
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/lber-0.1.2/src/parse.rs:43
   8:     0x558bc3235bce - lber::parse::parse_tag::h5a3fee992fee48d4
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/lber-0.1.2/src/parse.rs:85
   9:     0x558bc3237345 - <lber::parse::Parser as nom::stream::Consumer<&'a [u8], lber::structure::StructureTag, (), nom::stream::Move>>::handle::h3de6a131057495e7
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/lber-0.1.2/src/parse.rs:137
  10:     0x558bc31e73c2 - <ldap3::protocol::LdapCodec as tokio_io::framed_read::Decoder>::decode::h212546f1559cebe9
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/ldap3-0.4.0/src/protocol.rs:166
  11:     0x558bc31dbbc2 - <tokio_io::framed::Fuse<T, U> as tokio_io::framed_read::Decoder>::decode::hb0764558ea721a39
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-io-0.1.1/src/framed.rs:144
  12:     0x558bc31dda0b - <tokio_io::framed_write::FramedWrite2<T> as tokio_io::framed_read::Decoder>::decode::hed6a4f34cbea190c
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-io-0.1.1/src/framed_write.rs:231
  13:     0x558bc31d7d40 - <tokio_io::framed_read::FramedRead2<T> as futures::stream::Stream>::poll::h0555418f9df7002e
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-io-0.1.1/src/framed_read.rs:257
  14:     0x558bc31d666b - <tokio_io::framed::Framed<T, U> as futures::stream::Stream>::poll::h771abbc924b37f67
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-io-0.1.1/src/framed.rs:69
  15:     0x558bc31eb9c1 - <ldap3::protocol::ResponseFilter<T> as futures::stream::Stream>::poll::h2f5a338a4f829ecb
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/ldap3-0.4.0/src/protocol.rs:342
  16:     0x558bc311209f - <tokio_proto::simple::multiplex::lift::LiftTransport<T, E> as futures::stream::Stream>::poll::hdea1d69a3cb94c08
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-proto-0.1.1/src/simple/multiplex/mod.rs:49
  17:     0x558bc31a0337 - <tokio_proto::streaming::multiplex::advanced::Multiplex<T>>::read_out_frames::hf7002a8a5ef2d2ce
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-proto-0.1.1/src/streaming/multiplex/advanced.rs:307
  18:     0x558bc310e46b - <tokio_proto::streaming::multiplex::advanced::Multiplex<T> as futures::future::Future>::poll::h20866d436ef91aa3
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-proto-0.1.1/src/streaming/multiplex/advanced.rs:795
  19:     0x558bc31827a7 - <futures::future::chain::Chain<A, B, C>>::poll::h03d63a5108c8b895
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/future/chain.rs:32
  20:     0x558bc310c4db - <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll::h78985ae2502bc612
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/future/and_then.rs:32
  21:     0x558bc31dd266 - <futures::future::map_err::MapErr<A, F> as futures::future::Future>::poll::h50903988af884f2f
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/future/map_err.rs:30
  22:     0x558bc3262951 - <alloc::boxed::Box<F> as futures::future::Future>::poll::h27ca483f4ce6d38d
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/future/mod.rs:106
  23:     0x558bc324e50c - <futures::task_impl::Spawn<F>>::poll_future::{{closure}}::hd3c2f27a5fda7ad1
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:337
  24:     0x558bc324e90e - <futures::task_impl::Spawn<T>>::enter::{{closure}}::hbb6f5ccd6fc5b025
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:484
  25:     0x558bc3263ec3 - futures::task_impl::set::{{closure}}::h499fe6f33b803efd
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:61
  26:     0x558bc3250037 - <std::thread::local::LocalKey<T>>::with::h3ba01bdceea4f38b
                               at /checkout/src/libstd/thread/local.rs:253
  27:     0x558bc3263def - futures::task_impl::set::heaa71f1d8948603b
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:54
  28:     0x558bc324e6ee - <futures::task_impl::Spawn<T>>::enter::h1f684d644281cf4c
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:484
  29:     0x558bc324e497 - <futures::task_impl::Spawn<F>>::poll_future::h5dfdfec0256cccdb
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.13/src/task_impl/mod.rs:337
  30:     0x558bc326de72 - tokio_core::reactor::Core::dispatch_task::{{closure}}::he46c652d12cad851
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.6/src/reactor/mod.rs:366
  31:     0x558bc324ac54 - <scoped_tls::ScopedKey<T>>::set::h3b3b778d236098b9
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.0/src/lib.rs:135
  32:     0x558bc326d9b8 - tokio_core::reactor::Core::dispatch_task::h2ca8f82a3a2b061c
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.6/src/reactor/mod.rs:366
  33:     0x558bc326cf05 - tokio_core::reactor::Core::dispatch::he76054210341683f
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.6/src/reactor/mod.rs:324
  34:     0x558bc326ca6b - tokio_core::reactor::Core::poll::ha5e0c2568b9e79a4
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.6/src/reactor/mod.rs:312
  35:     0x558bc30dc18f - tokio_core::reactor::Core::run::h569afbfac3d250cf
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.6/src/reactor/mod.rs:249
  36:     0x558bc30fd9af - ldap3::conn::LdapConn::search::hd959802497ae9e1e
                               at /home/clux/.cargo/registry/src/github.com-1ecc6299db9ec823/ldap3-0.4.0/src/conn.rs:153
  37:     0x558bc310b953 - ldap::main::h9a091a483f4d5cab
                               at /home/clux/sqbu/propagator/tests/ldap.rs:7
  38:     0x558bc32d2d85 - std::panicking::try::do_call::h689a21caeeef92aa
                               at /checkout/src/libcore/ops.rs:2606
                               at /checkout/src/libstd/panicking.rs:454
  39:     0x558bc32d9f1a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  40:     0x558bc32d382a - std::rt::lang_start::hf63d494cb7dd034c
                               at /checkout/src/libstd/panicking.rs:433
                               at /checkout/src/libstd/panic.rs:361
                               at /checkout/src/libstd/rt.rs:57
  41:     0x558bc310bb42 - main
  42:     0x7fad8d1d9510 - __libc_start_main
  43:     0x558bc30db1d9 - _start
  44:                0x0 - <unknown>

Should be on the latest version:

cat Cargo.lock | grep ldap3
 "ldap3 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
name = "ldap3"
"checksum ldap3 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f8ac9d8ba08b14d613c5405b2f08ba7857421d29b02f43ab27d561c3842397d"

Have you got any hints for debugging this?

inejge commented 7 years ago

I think I know what's causing this, and I've pushed a fix to master. Could you try it out by replacing the ldap3 dependency in your Cargo.toml with:

[dependencies.ldap3]
git = "https://github.com/inejge/ldap3"
rev = "9582a6c2860813d510487aae077ed44a692ad2b7"

and rebuilding?

clux commented 7 years ago

Yeah, that totally passes 😄

clux commented 7 years ago

For reference: result of the search is LdapResult { rc: 1, matched: "", text: "000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1\u{0}", refs: [] }

inejge commented 7 years ago

Great! I'll publish a new version on crates.io soon.

For posterity, integer parsing was one of things I forgot to fix in the rush to publish the first version of the crate. I did all my testing with OpenLDAP, which worked, and Active Directory probably encodes lengths in a slightly non-standard manner, which triggered the bug.

Thanks for the report!

clux commented 7 years ago

Thanks a lot for the fix 😄