mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/jazoff/fuzz-size-limit-speedup'
- Factored check into more descriptive function: ExceedsChunkLimit() * origin/topic/jazoff/fuzz-size-limit-speedup: Speed up ChunkCount validity check
This commit is contained in:
commit
05f829c727
4 changed files with 18 additions and 5 deletions
|
@ -14,18 +14,18 @@ bool zeek::detail::FuzzBuffer::Valid(int chunk_count_limit) const
|
|||
if ( memcmp(begin, PKT_MAGIC, PKT_MAGIC_LEN) != 0)
|
||||
return false;
|
||||
|
||||
if ( ChunkCount() > chunk_count_limit )
|
||||
if ( ExceedsChunkLimit(chunk_count_limit) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int zeek::detail::FuzzBuffer::ChunkCount() const
|
||||
int zeek::detail::FuzzBuffer::ChunkCount(int chunk_count_limit) const
|
||||
{
|
||||
auto pos = begin;
|
||||
int chunks = 0;
|
||||
|
||||
while ( pos < end )
|
||||
while ( pos < end && (chunks < chunk_count_limit || chunk_count_limit == 0) )
|
||||
{
|
||||
pos = (const unsigned char*)memmem(pos, end - pos,
|
||||
PKT_MAGIC, PKT_MAGIC_LEN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue