We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
ConfigBuilder::with_callback receives an owned cb the address of which is assigned to cfg.decode.context.
ConfigBuilder::with_callback
cb
cfg.decode.context
libipt-rs/src/config/config.rs
Line 230 in b312bc7
The callback is later invoked in decode_callback.
decode_callback
Line 201 in b312bc7
However, cb only lives until the end of with_callback. This can lead to use-after-free, as demonstrated by this test case below:
with_callback
#[test] fn test_bad_callback() { let mut data = [18; 3]; let c = { let counter = [1, 2, 3, 4, 5, 6, 7, 8]; ConfigBuilder::with_callback( &mut data, move |c, p| { assert_eq!(counter, [1, 2, 3, 4, 5, 6, 7, 8]); // counter points to freed memory (Unknown::new(c.0.cpu.model + p[0]), 1) }) }.unwrap().finish(); unsafe { let mut ukn: pt_packet_unknown = std::mem::zeroed(); let _ = c.0.decode.callback.unwrap()(&mut ukn, c.0.as_ref(), c.0.begin, c.0.decode.context); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ConfigBuilder::with_callback
receives an ownedcb
the address of which is assigned tocfg.decode.context
.libipt-rs/src/config/config.rs
Line 230 in b312bc7
The callback is later invoked in
decode_callback
.libipt-rs/src/config/config.rs
Line 201 in b312bc7
However,
cb
only lives until the end ofwith_callback
. This can lead to use-after-free, as demonstrated by this test case below:The text was updated successfully, but these errors were encountered: