From 4d31b8fd0f97f55f5500257dda91df989d5f67c5 Mon Sep 17 00:00:00 2001 From: Florent De Neve Date: Tue, 25 Jun 2024 14:12:11 +0200 Subject: [PATCH 1/2] Use set_match_limit_recursion in SREMatch --- libstuff/libstuff.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstuff/libstuff.cpp b/libstuff/libstuff.cpp index 42544bcb6..329c9ced0 100644 --- a/libstuff/libstuff.cpp +++ b/libstuff/libstuff.cpp @@ -2806,11 +2806,11 @@ bool SIsValidSQLiteDateModifier(const string& modifier) { } bool SREMatch(const string& regExp, const string& s) { - return pcrecpp::RE(regExp).FullMatch(s); + return pcrecpp::RE(regExp, pcrecpp::RE_Options().set_match_limit_recursion(1000)).FullMatch(s); } bool SREMatch(const string& regExp, const string& s, string& match) { - return pcrecpp::RE(regExp).FullMatch(s, &match); + return pcrecpp::RE(regExp, pcrecpp::RE_Options().set_match_limit_recursion(1000)).FullMatch(s, &match); } void SRedactSensitiveValues(string& s) { From 9ee40c767c46d820ddf89c3cb894074d7cde479b Mon Sep 17 00:00:00 2001 From: Cole Eason Date: Tue, 25 Jun 2024 22:09:59 +0000 Subject: [PATCH 2/2] Make SRandom not require a reference --- libstuff/SRandom.cpp | 6 +++--- libstuff/SRandom.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libstuff/SRandom.cpp b/libstuff/SRandom.cpp index b6900dac6..d864589a8 100644 --- a/libstuff/SRandom.cpp +++ b/libstuff/SRandom.cpp @@ -18,13 +18,13 @@ uint64_t SRandom::rand64() { return _distribution64(_generator); } -string SRandom::randStr(uint& length) { +string SRandom::randStr(uint length) { string str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; string newstr; int pos; - while(newstr.size() != length) { + while (newstr.size() != length) { pos = (rand64() % (str.size() - 1)); - newstr += str.substr(pos,1); + newstr += str.substr(pos, 1); } return newstr; } diff --git a/libstuff/SRandom.h b/libstuff/SRandom.h index a718a04cd..9058206ea 100644 --- a/libstuff/SRandom.h +++ b/libstuff/SRandom.h @@ -10,7 +10,7 @@ class SRandom { public: static uint64_t rand64(); static uint64_t limitedRand64(uint64_t min, uint64_t max); - static string randStr(uint& length); + static string randStr(uint length); private: static mt19937_64 _generator;