1wilkens / pam-sys

Rust FFI bindings to the Linux Pluggable Authentication Modules (PAM)
https://docs.rs/pam-sys/
Apache License 2.0
18 stars 20 forks source link

Clippy lints #7

Closed blm768 closed 5 years ago

blm768 commented 5 years ago

Running clippy against master produces a couple of lint failures:

warning: Comparing with null is better expressed by the .is_null() method
   --> src/wrapped.rs:121:12
    |
121 |         if env != ptr::null(){
    |            ^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(clippy::cmp_null)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cmp_null

error: this public function dereferences a raw pointer but is not marked `unsafe`
   --> src/wrapped.rs:206:17
    |
206 |                 prompt
    |                 ^^^^^^
    |
    = note: `#[deny(clippy::not_unsafe_ptr_arg_deref)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

The second could theoretically lead to undefined behavior if the user passes an expired pointer. Either marking the function as unsafe or changing the type of the prompt argument to Option<&CStr> should fix the issue.