Skip to content

Cannot list iODBC drivers: Buffer must contain terminating zero #502

@matthewgapp

Description

@matthewgapp

Getting Buffer must contain terminating zero. when trying to list drivers with the iodbc feature flag enabled on mac.

Minimal repro:

Step 1: enable the iodbc feature:

odbc-api = { version = "5.0.0", features = ["iodbc"] }

Step 2: run this code:

use odbc_api::Environment;

fn main() {
    let env = Environment::new().unwrap();
    let drivers = env.drivers();
    println!("Drivers: {:?}", drivers);
}

You'll get this error

thread 'main' panicked at /Users/matthewgapp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/odbc-api-5.0.0/src/handles/sql_char.rs:63:10:
Buffer must contain terminating zero.
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_display
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:168:5
   3: core::panicking::panic_str
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:152:5
   4: core::option::expect_failed
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/option.rs:1988:5
   5: core::option::Option<T>::expect
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/option.rs:898:21
   6: odbc_api::handles::sql_char::sz_to_utf8
             at /Users/matthewgapp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/odbc-api-5.0.0/src/handles/sql_char.rs:59:15
   7: odbc_api::handles::sql_char::SzBuffer::to_utf8
             at /Users/matthewgapp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/odbc-api-5.0.0/src/handles/sql_char.rs:174:9
   8: odbc_api::environment::Environment::drivers
             at /Users/matthewgapp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/odbc-api-5.0.0/src/environment.rs:520:35
   9: odbc_api_driver_bug_test::main
             at ./src/main.rs:5:19
  10: core::ops::function::FnOnce::call_once
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Some background: I'm trying to get iodbc to work on my mac because we need to connect to snowflake, which doesn't support unixodbc on mac. So downstream, I'm enabling the iodbc feature flag on. Would be very helpful to list out the drivers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions