andrew-d / andrew-d/tinycdb-rs

Unsound usages of unsafe implementation about c_void

Đang mở
#6 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C
Star
5
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi, I am scanning this crate in the latest version using my own static analyzer tool.

Unsafe pointer conversion is found at:
```rust
pub fn add(&mut self, key: &[u8], val: &[u8]) -> CdbResult<()> {
let res = unsafe {
ffi::cdb_make_add(
self.cdbm_mut_ptr(),
key.as_ptr() as *const c_void,
key.len() as c_uint,
val.as_ptr() as *const c_void,
val.len() as c_uint,
)
};
match res {
x if x < 0 => Err(CdbError::new_from_errno("Error adding key/value")),
_ => Ok(()),
}
}
```

This unsound implementation would create memory issues such as overflow, underflow, or misalignment. The attacker can manipulate the `key` and `val` arguments, which can lead to buffer overflow bug. This can further corrupt the C/C++ code.

This would cause [undefined behaviors](https://doc.rust-lang.org/reference/behavior-considered-undefined.html) in Rust. I am reporting this issue for your attention.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.