File: 209.patch

package info (click to toggle)
libapache2-mod-auth-cas 1.2-1.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,772 kB
  • sloc: sh: 4,181; ansic: 4,156; makefile: 102
file content (176 lines) | stat: -rw-r--r-- 6,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
From 486fce9fda27f6708ac9f6be53b7ba71c3a9b4e0 Mon Sep 17 00:00:00 2001
From: "Scott A. Williams" <vwfoxguru@gmail.com>
Date: Fri, 3 Mar 2023 18:35:27 -0800
Subject: [PATCH 1/4] Port pcre calls to pcre2.

Signed-off-by: Scott A. Williams <vwfoxguru@gmail.com>
---
 README             |  2 +-
 README.win32       |  2 +-
 config.h.in        |  2 +-
 configure          | 12 ++++++------
 configure.ac       |  4 ++--
 src/mod_auth_cas.c | 12 ++++++------
 6 files changed, 17 insertions(+), 17 deletions(-)

Index: libapache2-mod-auth-cas-1.2/README
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/README
+++ libapache2-mod-auth-cas-1.2/README
@@ -49,7 +49,7 @@
 * Apache Portable Runtime Utilities - 1.2.7 or higher
 * Apache Web Server - 2.2.3 or higher
 * libcurl - 7.18.2 or higher
-* libpcre - 7.8 or higher
+* libpcre2 - 10 or higher
 
 Download the distribution via git or tarball.  Because git does not
 preserve timestamps, autoconf may determine it is necessary to bootstrap
Index: libapache2-mod-auth-cas-1.2/README.win32
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/README.win32
+++ libapache2-mod-auth-cas-1.2/README.win32
@@ -22,7 +22,7 @@
 NOTE:	As of mod_auth_cas 1.0.9, Win32 support has been dropped due
 	to lack of development resources and low community interest.
 	As a result, these instructions may be inaccurate.  As an
-	explicit example, the additional curl and libpcre dependencies are
+	explicit example, the additional curl and libpcre2 dependencies are
 	not addressed in these instructions at all.
 
 ====================================================================
Index: libapache2-mod-auth-cas-1.2/config.h.in
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/config.h.in
+++ libapache2-mod-auth-cas-1.2/config.h.in
@@ -15,7 +15,7 @@
 /* Define to 1 if you have a functional curl library. */
 #undef HAVE_LIBCURL
 
-/* Define to 1 if you have the `pcre' library (-lpcre). */
+/* Define to 1 if you have the `pcre2' library (-lpcre2). */
 #undef HAVE_LIBPCRE
 
 /* Define to 1 if you have the `ssl' library (-lssl). */
Index: libapache2-mod-auth-cas-1.2/configure
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/configure
+++ libapache2-mod-auth-cas-1.2/configure
@@ -14129,14 +14129,14 @@
   unset _libcurl_with
 
 
-# Checks for libpcre
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
-$as_echo_n "checking for pcre_compile in -lpcre... " >&6; }
+# Checks for libpcre2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre2_compile in -lpcre2" >&5
+$as_echo_n "checking for pcre2_compile in -lpcre2... " >&6; }
 if ${ac_cv_lib_pcre_pcre_compile+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpcre  $LIBS"
+LIBS="-lpcre2  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -14146,11 +14146,11 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char pcre_compile ();
+char pcre2_compile ();
 int
 main ()
 {
-return pcre_compile ();
+return pcre2_compile ();
   ;
   return 0;
 }
@@ -14171,10 +14171,10 @@
 #define HAVE_LIBPCRE 1
 _ACEOF
 
-  LIBS="-lpcre $LIBS"
+  LIBS="-lpcre2 $LIBS"
 
 else
-  as_fn_error $? "libpcre required" "$LINENO" 5
+  as_fn_error $? "libpcre2 required" "$LINENO" 5
 fi
 
 
Index: libapache2-mod-auth-cas-1.2/configure.ac
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/configure.ac
+++ libapache2-mod-auth-cas-1.2/configure.ac
@@ -137,8 +137,8 @@
 #### Check for libcurl
 LIBCURL_CHECK_CONFIG([yes],[],[],[AC_MSG_ERROR([libcurl development files required])])
 
-# Checks for libpcre
-AC_CHECK_LIB([pcre], [pcre_compile], [], [AC_MSG_ERROR([libpcre required])])
+# Checks for libpcre2
+AC_CHECK_LIB([pcre2-8], [pcre2_compile_8], [], [AC_MSG_ERROR([libpcre2 required])])
 
 # Checks for header files.
 AC_CHECK_HEADERS([netdb.h stddef.h sys/socket.h unistd.h])
Index: libapache2-mod-auth-cas-1.2/src/mod_auth_cas.c
===================================================================
--- libapache2-mod-auth-cas-1.2.orig/src/mod_auth_cas.c
+++ libapache2-mod-auth-cas-1.2/src/mod_auth_cas.c
@@ -44,7 +44,8 @@
 #include "util_md5.h"
 #include "ap_config.h"
 #include "ap_release.h"
-#include "pcre.h"
+#define  PCRE2_CODE_UNIT_WIDTH 8
+#include "pcre2.h"
 #include "apr_buckets.h"
 #include "apr_file_info.h"
 #include "apr_lib.h"
@@ -2380,32 +2381,35 @@
 		 * name and the attr_spec is a tilde (denotes a PCRE match). */
 		else if (!(*attr_c) && (*spec_c) == '~') {
 			const cas_saml_attr_val *val;
-			const char *errorptr;
-			int erroffset;
-			pcre *preg;
+			int errorcode;
+			PCRE2_SIZE erroffset;
+			pcre2_code *preg;
+			uint32_t options = PCRE2_UTF;
+			pcre2_match_data *preg_match;
 
 			/* Skip the tilde */
 			spec_c++;
 
 			/* Set up the regex */
-			preg = pcre_compile(spec_c, 0, &errorptr, &erroffset, NULL);
+			preg = pcre2_compile((PCRE2_SPTR)spec_c, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroffset, NULL);
 			if (NULL == preg) {
 				ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Pattern [%s] is not a valid regular expression", spec_c);
 				continue;
 			}
 
 			/* Compare the attribute values */
+			preg_match = pcre2_match_data_create_from_pattern(preg, NULL);
 			val = attr->values;
 			for ( ; val; val = val->next) {
 				/* PCRE-compare the attribute value. At this point, spec_c
 				 * points to the NULL-terminated value pattern. */
-				if (0 == pcre_exec(preg, NULL, val->value, (int)strlen(val->value), 0, 0, NULL, 0)) {
-					pcre_free(preg);
+				if (0 <= pcre2_match(preg, (PCRE2_SPTR)val->value, (int)strlen(val->value), 0, 0, preg_match, 0)) {
+					pcre2_match_data_free(preg_match);
 					return CAS_ATTR_MATCH;
 				}
 			}
 
-			pcre_free(preg);
+			pcre2_match_data_free(preg_match);
 		}
 	}
 	return CAS_ATTR_NO_MATCH;