~ireas/nitrokey-rs

944773f80bfc3106b4734e9cf3407eaff3b61082 — Robin Krahl 8 months ago f3d541e
Correctly free pointer to PWS status

The NK_get_password_safe_slot_status function returns a pointer to an
array that has been allocated using new[].  As we only have access to
libc’s free function, we could not free this pointer properly (using
delete[]).  libnitrokey 3.6 added the NK_free_password_safe_slot_status
function which we now use to properly free the pointer.
3 files changed, 3 insertions(+), 2 deletions(-)

M CHANGELOG.md
M TODO.md
M src/pws.rs
M CHANGELOG.md => CHANGELOG.md +2 -0
@@ 13,6 13,8 @@ SPDX-License-Identifier: CC0-1.0
- Update the `nitrokey-sys` dependency to v3.6.0.
  - Use `NK_device_serial_number_as_u32` instead of `NK_device_serial_number`
    in `Device::get_serial_number`.
  - Use `NK_free_password_safe_slot_status` to free the pointer returned by
    `NK_get_password_safe_slot_status` in `PasswordSafe::get_slot_status`.

# v0.7.1 (2020-08-30)
- Remove the custom `std::error::Error::source` implementation for

M TODO.md => TODO.md +0 -1
@@ 17,6 17,5 @@ SPDX-License-Identifier: CC0-1.0
    - `NK_write_config_struct`
    - `NK_free_config`
    - `NK_read_config_struct`
    - `NK_free_password_safe_slot_status`

[nitrokey-storage-firmware issue 65]: https://github.com/Nitrokey/nitrokey-storage-firmware/issues/65

M src/pws.rs => src/pws.rs +1 -1
@@ 173,7 173,7 @@ impl<'a, 'b> PasswordSafe<'a, 'b> {
            result[i as usize] = status_array[i as usize] == 1;
        }
        unsafe {
            libc::free(status_ptr as *mut libc::c_void);
            nitrokey_sys::NK_free_password_safe_slot_status(status_ptr);
        }
        Ok(result)
    }