rust-rocksdb icon indicating copy to clipboard operation
rust-rocksdb copied to clipboard

simplify impl of read table properties

Open Connor1996 opened this issue 4 years ago • 2 comments

Rudra complains about the potential double-free issue https://paper.seebug.org/1728/#05-panic-safety-double-free-rustsec-2021-0011, so simplify it to avoid using mem::forgot

// Warning (UnsafeDataflow:/ReadFlow): Potential unsafe dataflow issue in 
// `rocksdb::SstFileReader::read_table_properties::callback`
// -> src/rocksdb.rs:2330:9: 2338:10
extern "C" fn callback<F: FnOnce(&TableProperties)>(
            ctx: *mut c_void,
            ptr: *const crocksdb_ffi::DBTableProperties,
        ) {
            unsafe {
                let caller = ptr::read(ctx as *mut F);
                caller(TableProperties::from_ptr(ptr));
            }
        }

Connor1996 avatar Nov 16 '21 12:11 Connor1996

/test

Connor1996 avatar Nov 17 '21 07:11 Connor1996

/build

Connor1996 avatar Nov 17 '21 07:11 Connor1996