Axel Beckert wrote: > sorry for the late reply, but I only managed to continue on this now > as I'm on holidays now.
No problem at all, we are all busy. And it's not late according to my standards. :) > I though got another crash on this line: > > Dec 24 06:43:16 c6 kernel: net_ratelimit: 1 callbacks suppressed Good catch! This is a case when process is allocated by pcre2_substring_get_bynumber but since there are no square brackets around, the strdup call at line 68 doesn't happen. > I think I managed to fix it and will also upload, but I'd be happy for > a short review of yours: Removing the free call avoids the abort but leads to a memory leak. Attached is a better fix, I think (tested with your line above and my syslog, and of course with valgrind).
diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch index a5ee6b3..334d4e3 100644 --- a/debian/patches/pcre2.patch +++ b/debian/patches/pcre2.patch @@ -2473,7 +2473,7 @@ Last-Update: 2023-12-24 { char *date = NULL, *host = NULL, *send = NULL, *process = NULL; char *msg = NULL, *pid = NULL, *tmp = NULL, *toret; -+ int use_free = 0; ++ int msg_use_free = 0, process_use_free = 0; + size_t l; - pcre_get_substring (str, offsets, match, 1, (const char **)&date); @@ -2488,7 +2488,7 @@ Last-Update: 2023-12-24 - msg = strdup (send); + { + msg = strdup (send); -+ use_free = 1; ++ msg_use_free = 1; + } else { @@ -2499,7 +2499,7 @@ Last-Update: 2023-12-24 } if (process) -@@ -60,8 +64,8 @@ +@@ -60,8 +64,9 @@ pid = strndup (&t[1], (size_t)(t2 - t - 1)); tmp = strndup (process, (size_t)(t - process)); @@ -2507,10 +2507,11 @@ Last-Update: 2023-12-24 - process = tmp; + pcre2_substring_free (process); + process = strdup (tmp); ++ process_use_free = 1; } } -@@ -87,12 +91,17 @@ +@@ -87,12 +92,20 @@ else toret = strdup (send); @@ -2522,18 +2523,21 @@ Last-Update: 2023-12-24 + pcre2_substring_free (date); + pcre2_substring_free (host); + pcre2_substring_free (send); -+ /* free (process); */ free (pid); + free (tmp); + -+ if (use_free) ++ if (process_use_free) ++ free (process); ++ else ++ pcre2_substring_free (process); ++ if (msg_use_free) + free (msg); + else + pcre2_substring_free (msg); return toret; } -@@ -100,33 +109,34 @@ +@@ -100,33 +113,34 @@ static void ccze_syslog_setup (void) {