[Privoxy-devel] PATCH for pcre2 support

Gagan Sidhu broly at mac.com
Thu Mar 9 13:22:40 CET 2023


hi fabian,

yes there were, but that’s the old patch and i suspect it wouldn’t work because i screwed up the assignment of the dummy variable.

i believe i uploaded a newer patch to the sourceforge that fixes that problem.

i checked the uploaded patch and saw it was unchanged, because i forgot to add the ‘>’ when doing a “git diff <patchname>”

can you try the newer patch and report back?

there should only two minor warnings now over the const qualifier:

> pcrs.c: In function 'pcrs_compile':
> pcrs.c:671:37: warning: passing argument 2 of 'pcre2_get_error_message_8' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>   671 |    pcre2_get_error_message(errcode, error, 128);
>       |                                     ^~~~~
> In file included from project.h:109,
>                  from pcrs.c:47:
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:805:50: note: expected 'PCRE2_UCHAR8 *' {aka 'unsigned char *'} but argument is of type 'const char *'
>   805 | #define PCRE2_UCHAR                 PCRE2_SUFFIX(PCRE2_UCHAR)
>       |                                                  ^
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:798:25: note: in definition of macro 'PCRE2_JOIN'
>   798 | #define PCRE2_JOIN(a,b) a ## b
>       |                         ^
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:800:25: note: in expansion of macro 'PCRE2_GLUE'
>   800 | #define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
>       |                         ^~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:805:37: note: in expansion of macro 'PCRE2_SUFFIX'
>   805 | #define PCRE2_UCHAR                 PCRE2_SUFFIX(PCRE2_UCHAR)
>       |                                     ^~~~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:785:32: note: in expansion of macro 'PCRE2_UCHAR'
>   785 |   pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \
>       |                                ^~~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:932:1: note: in expansion of macro 'PCRE2_OTHER_FUNCTIONS'
>   932 | PCRE2_OTHER_FUNCTIONS
>       | ^~~~~~~~~~~~~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:935:1: note: in expansion of macro 'PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS'
>   935 | PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> pcrs.c: In function 'pcrs_execute':
> pcrs.c:874:51: warning: pointer targets in passing argument 2 of 'pcre2_match_8' differ in signedness [-Wpointer-sign]
>   874 |    while ((submatches = pcre2_match(job->pattern, subject, (int)subject_length, offset, 0, pcre2_matches, NULL)) > 0)
>       |                                                   ^~~~~~~
>       |                                                   |
>       |                                                   const char *
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:806:50: note: expected 'PCRE2_SPTR8' {aka 'const unsigned char *'} but argument is of type 'const char *'
>   806 | #define PCRE2_SPTR                  PCRE2_SUFFIX(PCRE2_SPTR)
>       |                                                  ^~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:798:25: note: in definition of macro 'PCRE2_JOIN'
>   798 | #define PCRE2_JOIN(a,b) a ## b
>       |                         ^
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:800:25: note: in expansion of macro 'PCRE2_GLUE'
>   800 | #define PCRE2_SUFFIX(a) PCRE2_GLUE(a,PCRE2_LOCAL_WIDTH)
>       |                         ^~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:806:37: note: in expansion of macro 'PCRE2_SUFFIX'
>   806 | #define PCRE2_SPTR                  PCRE2_SUFFIX(PCRE2_SPTR)
>       |                                     ^~~~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:682:35: note: in expansion of macro 'PCRE2_SPTR'
>   682 |   pcre2_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
>       |                                   ^~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:927:1: note: in expansion of macro 'PCRE2_MATCH_FUNCTIONS'
>   927 | PCRE2_MATCH_FUNCTIONS \
>       | ^~~~~~~~~~~~~~~~~~~~~
> /Volumes/xtoolshit/misc/dd-wrt/src/router/mipsel/install/glib20/usr/include/pcre2.h:935:1: note: in expansion of macro 'PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS'
>   935 | PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Thanks,
Gagan

> On Mar 9, 2023, at 3:57 AM, Fabian Keil <fk at fabiankeil.de> wrote:
> 
> Gagan Sidhu <broly at mac.com> wrote on 2023-03-08 at 11:45:27:
> 
>> i’ve updated the patch because i stupidly used the dummy variable, which i didn’t pay attention to.
>> 
>> i create a new variable but the rest of the behaviour should be the same.
>> 
>> i also call pcre2_error_message so that the character string is returned instead of just using what was there.
> 
> Thanks a lot for working on this, Gagan.
> 
> Looks like there are quite a few warnings:
> 
> fk at t520 ~/git/privoxy $gmake
> cc -c -pipe -fstack-protector-all -ggdb -Wshadow  -Wconversion -I/usr/local/include/  -pthread -Wall  actions.c -o actions.o
> [...]
> cc -c -pipe -fstack-protector-all -ggdb -Wshadow  -Wconversion -I/usr/local/include/  -pthread -Wall  pcrs.c -o pcrs.o
> pcrs.c:669:20: warning: incompatible pointer types passing 'const char **' to parameter of type 'int *' [-Wincompatible-pointer-types]
>                   &error, errptr, NULL);
>                   ^~~~~~
> /usr/local/include/pcre2.h:935:1: note: passing argument to parameter here
> PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
> ^
> /usr/local/include/pcre2.h:924:31: note: expanded from macro 'PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS'
> PCRE2_MATCH_CONTEXT_FUNCTIONS \
>                              ^
> /usr/local/include/pcre2.h:650:57: note: expanded from macro '\
> PCRE2_COMPILE_FUNCTIONS'
>  *pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, \
>                                                        ^
> pcrs.c:669:28: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]
>                   &error, errptr, NULL);
>                           ^~~~~~
> /usr/local/include/pcre2.h:935:1: note: passing argument to parameter here
> PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
> ^
> /usr/local/include/pcre2.h:924:31: note: expanded from macro 'PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS'
> PCRE2_MATCH_CONTEXT_FUNCTIONS \
>                              ^
> /usr/local/include/pcre2.h:650:71: note: expanded from macro '\
> PCRE2_COMPILE_FUNCTIONS'
>  *pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, \
>                                                                      ^
> pcrs.c:668:100: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
>   newjob->pattern = pcre2_compile((const unsigned char *) pattern, PCRE2_ZERO_TERMINATED, newjob->options,
>                     ~~~~~~~~~~~~~                                                         ~~~~~~~~^~~~~~~
> pcrs.c:872:51: warning: passing 'const char *' to parameter of type 'PCRE2_SPTR8' (aka 'const unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
>   while ((submatches = pcre2_match(job->pattern, subject, (int)subject_length, offset, 0, dummy, NULL)) > 0)
>                                                  ^~~~~~~
> /usr/local/include/pcre2.h:935:1: note: passing argument to parameter here
> PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
> ^
> /usr/local/include/pcre2.h:926:30: note: expanded from macro 'PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS'
> PCRE2_PATTERN_INFO_FUNCTIONS \
>                             ^
> /usr/local/include/pcre2.h:682:45: note: expanded from macro '\
> PCRE2_MATCH_FUNCTIONS'
>  pcre2_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
>                                            ^
> pcrs.c:872:81: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
>   while ((submatches = pcre2_match(job->pattern, subject, (int)subject_length, offset, 0, dummy, NULL)) > 0)
>                        ~~~~~~~~~~~                                             ^~~~~~
> pcrs.c:872:60: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
>   while ((submatches = pcre2_match(job->pattern, subject, (int)subject_length, offset, 0, dummy, NULL)) > 0)
>                        ~~~~~~~~~~~                        ^~~~~~~~~~~~~~~~~~~
> pcrs.c:907:29: warning: incompatible pointer types assigning to 'pcre2_match_data_8 *' (aka 'struct pcre2_real_match_data_8 *') from 'pcrs_match *' [-Wincompatible-pointer-types]
>         if (NULL == (dummy = (pcrs_match *)realloc(matches, (size_t)max_matches * sizeof(pcrs_match))))
>                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> pcrs.c:912:18: warning: incompatible pointer types assigning to 'pcrs_match *' from 'pcre2_match_data_8 *' (aka 'struct pcre2_real_match_data_8 *') [-Wincompatible-pointer-types]
>         matches = dummy;
>                 ^ ~~~~~
> pcrs.c:854:49: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
>   if (NULL == (dummy = pcre2_match_data_create((size_t)max_matches, NULL)))
>                        ~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
> pcrs.c:882:42: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
>         matches[i].submatch_offset[k] = offsets[2 * k];
>                                       ~ ^~~~~~~~~~~~~~
> pcrs.c:899:61: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
>      matches[i].submatch_offset[PCRS_MAX_SUBMATCHES + 1] = offsets[1];
>                                                          ~ ^~~~~~~~~~
> pcrs.c:926:19: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
>         offset = offsets[1];
>                ~ ^~~~~~~~~~
> 12 warnings generated.
> 
> While briefly testing it I noticed the CGI pages (http://p.p/)
> no longer work:
> 
> fk at t520 ~ $curl --head https://p.p/
> HTTP/1.1 200 Connection established
> 
> HTTP/1.1 200 OK
> Content-Length: 0
> Content-Type: text/html
> Cache-Control: no-cache
> Date: Thu, 09 Mar 2023 10:56:17 GMT
> Last-Modified: Thu, 09 Mar 2023 10:56:17 GMT
> Expires: Sat, 17 Jun 2000 12:00:00 GMT
> Pragma: no-cache
> 
> Fabian



More information about the Privoxy-devel mailing list