Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hyperscan/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static int hs_match_handler(
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
PyObject *rv = PyObject_CallFunction(
cctx->callback, "IIIIO", id, from, to, flags, cctx->ctx);
cctx->callback, "IKKIO", id, from, to, flags, cctx->ctx);
int halt = 1;
if (rv == NULL) {
cctx->success = 0;
Expand Down Expand Up @@ -273,7 +273,7 @@ static int ch_match_handler(
}
PyObject *rv = PyObject_CallFunction(
cctx->callback,
"IIIIOO",
"IKKIOO",
id,
from,
to,
Expand Down
27 changes: 27 additions & 0 deletions tests/test_hyperscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,30 @@ def on_test_match(pattern_id, from_offset, to_offset, flags, context):

test_db.scan(b"test", match_event_handler=on_test_match)
assert len(test_matches) > 0, "Basic pattern matching should work"


def test_vectored_scan_large_offset(database_vector, mocker):
callback = mocker.Mock(return_value=None)
buffers = [
b"x"*(2**32-1),
b"fo"
]
database_vector.scan(buffers, match_event_handler=callback)
callback.assert_has_calls(
[
mocker.call(0,0,2**32+1,0,None),
],
any_order=True
)


def test_stream_scan_large_offset(database_stream, mocker):
callback = mocker.Mock(return_value=None)
with database_stream.stream(match_event_handler=callback) as stream:
stream.scan(b"x"*(2**32-1))
stream.scan(b"fo")
callback.assert_has_calls(
[
mocker.call(0,0,2**32+1,0,None)
]
)