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

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

Open
matthewgapp opened this issue Jan 15, 2024 · 3 comments
Open

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

matthewgapp opened this issue Jan 15, 2024 · 3 comments

Comments

@matthewgapp
Copy link

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.

@matthewgapp matthewgapp changed the title Cannot list iODBC drivers Cannot list iODBC drivers: Buffer must contain terminating zero Jan 15, 2024
@pacman82
Copy link
Owner

This is a Bug in iodbc. It is with the implementation of SQLDrivers. In this case the pointer to the buffer passed to SQLDrivers did not as commended by the ODBC standard contain a zero terminated string after the call.

Nothing odbc-api can do about this. If you find an upstream issue of iodbc we can track here, or create one in their GitHub and want to link it here I would keep this issue open in order to do so. Otherwise I would close the issue.

@matthewgapp
Copy link
Author

This is a Bug in iodbc. It is with the implementation of SQLDrivers. In this case the pointer to the buffer passed to SQLDrivers did not as commended by the ODBC standard contain a zero terminated string after the call.

Nothing odbc-api can do about this. If you find an upstream issue of iodbc we can track here, or create one in their GitHub and want to link it here I would keep this issue open in order to do so. Otherwise I would close the issue.

Thank you for looking into it. I didn't find an existing issue so I created a new one openlink/iODBC#98.

@pacman82
Copy link
Owner

thanks

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

No branches or pull requests

2 participants