Skip to content

Commit

Permalink
types: Make it work on 32-bit platforms
Browse files Browse the repository at this point in the history
This adds explicit conversion from platform dependent integer types
generated with bindgen to make it compile on both 32-bit and 64-bit
platforms.

Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Apr 11, 2024
1 parent 3afcafa commit 7947a15
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crypto-auditing/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ impl EventGroup {
/// Deserializes an event group from bytes
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Box<dyn std::error::Error>> {
let header = bytes.as_ptr() as *mut audit_event_header_st;
let context = unsafe { format_context((*header).pid_tgid, (*header).context) };
let ktime = unsafe { Duration::from_nanos((*header).ktime) };
let context = unsafe { format_context((*header).pid_tgid.into(), (*header).context.into()) };
let ktime = unsafe { Duration::from_nanos((*header).ktime.into()) };
let event = match unsafe { (*header).type_ } {
audit_event_type_t::AUDIT_EVENT_NEW_CONTEXT => {
let raw_new_context = bytes.as_ptr() as *mut audit_new_context_event_st;
let parent =
unsafe { format_context((*header).pid_tgid, (*raw_new_context).parent) };
unsafe { format_context((*header).pid_tgid.into(), (*raw_new_context).parent.into()) };
let origin = unsafe {
(*raw_new_context).origin[..(*raw_new_context).origin_size as usize].to_vec()
};
Expand All @@ -143,7 +143,7 @@ impl EventGroup {
end: ktime,
events: vec![Event::Data {
key: key.to_str()?.to_string(),
value: EventData::Word((*raw_word_data).value),
value: EventData::Word((*raw_word_data).value.into()),
}],
}
}
Expand Down

0 comments on commit 7947a15

Please sign in to comment.