[Privoxy-commits] [privoxy] 13/18: free_pattern_spec(): Don't try to free an invalid pointer

User Git git at git.privoxy.org
Fri Mar 5 06:35:56 UTC 2021


This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository privoxy.

commit 533193b4b79e68b938c82049c609906661177f9e
Author: Maxim Antonov <mantonov at gmail.com>
AuthorDate: Thu Mar 4 22:31:32 2021 +0700

    free_pattern_spec(): Don't try to free an invalid pointer
    
    ... when unloading an action file with a TAG pattern while
    Privoxy has been compiled without FEATURE_PCRE_HOST_PATTERNS.
    
       Thread 1 received signal SIGSEGV, Segmentation fault.
       0x00000008015a8bab in regfree (preg=0x800000000) at pcreposix.c:248
       248  pcreposix.c: No such file or directory.
       (gdb) where
       #0  0x00000008015a8bab in regfree (preg=0x800000000) at pcreposix.c:248
       #1  0x000000000045783a in free_pattern_spec (pattern=0x8029b9110) at urlmatch.c:1284
       #2  0x000000000040705f in unload_actions_file (file_data=0x8029b9070) at actions.c:1006
       #3  0x000000000044a146 in sweep () at loaders.c:248
       #4  0x0000000000439bfa in listen_loop () at jcc.c:6230
       #5  0x0000000000439456 in main (argc=3, argv=0x7fffffffe728) at jcc.c:5726
       (gdb) f 1
       #1  0x000000000045783a in free_pattern_spec (pattern=0x8029b9110) at urlmatch.c:1284
       1284       regfree(pattern->pattern.tag_regex);
       (gdb) p *pattern
       $1 = {spec = 0x0, pattern = {url_spec = {dcount = 0, dbuffer = 0x0, dvec = 0x0, unanchored = 0, port_list = 0x0, preg = 0x0}, tag_regex = 0x800000000}, flags = 16}
    
    Closes: SF patch request #147
---
 urlmatch.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/urlmatch.c b/urlmatch.c
index fa0e15d0..750cd242 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -1263,6 +1263,17 @@ void free_pattern_spec(struct pattern_spec *pattern)
    if (pattern == NULL) return;
 
    freez(pattern->spec);
+
+   if (!(pattern->flags & PATTERN_SPEC_URL_PATTERN))
+   {
+      if (pattern->pattern.tag_regex)
+      {
+         regfree(pattern->pattern.tag_regex);
+         freez(pattern->pattern.tag_regex);
+      }
+      return;
+   }
+
 #ifdef FEATURE_PCRE_HOST_PATTERNS
    if (pattern->pattern.url_spec.host_regex)
    {
@@ -1279,11 +1290,6 @@ void free_pattern_spec(struct pattern_spec *pattern)
       regfree(pattern->pattern.url_spec.preg);
       freez(pattern->pattern.url_spec.preg);
    }
-   if (pattern->pattern.tag_regex)
-   {
-      regfree(pattern->pattern.tag_regex);
-      freez(pattern->pattern.tag_regex);
-   }
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Privoxy-commits mailing list