Skip to content

id field in pattern and match callback does not match #34

@virusdefender

Description

@virusdefender

pub struct Pattern {
/// The expression to parse.
pub expression: String,
/// Flags which modify the behaviour of the expression.
pub flags: Flags,
/// ID number to be associated with the corresponding pattern in the expressions array.
pub id: Option<usize>,
/// Extended behaviour for this pattern
pub ext: ExprExt,
/// The precision to track start of match offsets in stream state.
pub som: Option<SomHorizon>,
}

the id field in Pattern is usize, but it's c_uint / u32 in the hs_compile_multi and match_event_handler

pub fn hs_compile_multi(
expressions: *const *const ::libc::c_char,
flags: *const ::libc::c_uint,
ids: *const ::libc::c_uint,
elements: ::libc::c_uint,
mode: ::libc::c_uint,
platform: *const hs_platform_info_t,
db: *mut *mut hs_database_t,
error: *mut *mut hs_compile_error_t,
) -> hs_error_t;
}

pub type match_event_handler = ::core::option::Option<
unsafe extern "C" fn(
id: ::libc::c_uint,
from: ::libc::c_ulonglong,
to: ::libc::c_ulonglong,
flags: ::libc::c_uint,
context: *mut ::libc::c_void,
) -> ::libc::c_int,
>;

if pattern.id > u32.Max, it will be truncated while compiling database, and then the callback id will be wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions