From bb85af5567e3fe3f515d4253c235ba891ce85439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=BCller=2C=20Jan?= Date: Mon, 21 Feb 2022 13:47:09 +0100 Subject: [PATCH] Fix runaway regex Multiple nested greedy quantifiers can cause to increase complexity of the regular expression so that the matching in the cmock_header_parser would take multiple minutes. Fixed by removing one of the quantifiers that seems not to be needed. --- lib/cmock_header_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 9730bf4..aaa1c8d 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -500,7 +500,7 @@ class CMockHeaderParser end # scan argument list for function pointers with shorthand notation and replace them with custom types - arg_list.gsub!(/([\w\s\*]+)+\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |_m| + arg_list.gsub!(/([\w\s\*]+)\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |_m| functype = "cmock_#{parse_project[:module_name]}_func_ptr#{parse_project[:typedefs].size + 1}" funcret = Regexp.last_match(1).strip funcname = Regexp.last_match(2).strip