Skip to content

Commit

Permalink
Merge pull request #3959 from bluca/fuzzers
Browse files Browse the repository at this point in the history
Problem: mtrie use of non-tail recursion leads to stack overflow
  • Loading branch information
somdoron authored Jun 17, 2020
2 parents b4aa912 + ab301eb commit 522abc7
Show file tree
Hide file tree
Showing 3 changed files with 487 additions and 382 deletions.
35 changes: 13 additions & 22 deletions src/generic_mtrie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,6 @@ template <typename T> class generic_mtrie_t
Arg arg_);

private:
bool add_helper (prefix_t prefix_, size_t size_, value_t *value_);
template <typename Arg>
void rm_helper (value_t *value_,
unsigned char **buff_,
size_t buffsize_,
size_t maxbuffsize_,
void (*func_) (prefix_t data_, size_t size_, Arg arg_),
Arg arg_,
bool call_on_uniq_);
template <typename Arg>
void rm_helper_multiple_subnodes (unsigned char **buff_,
size_t buffsize_,
size_t maxbuffsize_,
void (*func_) (prefix_t data_,
size_t size_,
Arg arg_),
Arg arg_,
bool call_on_uniq_,
value_t *pipe_);

rm_result rm_helper (prefix_t prefix_, size_t size_, value_t *value_);
bool is_redundant () const;

typedef std::set<value_t *> pipes_t;
Expand All @@ -113,12 +92,24 @@ template <typename T> class generic_mtrie_t
unsigned char _min;
unsigned short _count;
unsigned short _live_nodes;
union
union _next_t
{
class generic_mtrie_t<value_t> *node;
class generic_mtrie_t<value_t> **table;
} _next;

struct iter
{
generic_mtrie_t<value_t> *node;
generic_mtrie_t<value_t> *next_node;
prefix_t prefix;
size_t size;
unsigned short current_child;
unsigned char new_min;
unsigned char new_max;
bool processed_for_removal;
};

ZMQ_NON_COPYABLE_NOR_MOVABLE (generic_mtrie_t)
};
}
Expand Down
Loading

0 comments on commit 522abc7

Please sign in to comment.