Control: tags -1 + patch Please find attached a patch, build-tested only.
>From a214f32480e417c9bf3358652f96d29d51325560 Mon Sep 17 00:00:00 2001 From: Yavor Doganov <ya...@gnu.org> Date: Sun, 17 Dec 2023 14:23:39 +0200 Subject: [PATCH] Port to PCRE2 (#999965)
--- debian/changelog | 7 ++ debian/control | 2 +- debian/patches/pcre2.patch | 157 +++++++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 4 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 debian/patches/pcre2.patch diff --git a/debian/changelog b/debian/changelog index c43a915..20c1f63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +shadowsocks-libev (3.3.5+ds-11) UNRELEASED; urgency=medium + + * debian/patches/pcre2.patch: New; port to PCRE2 (Closes: #999965). + * debian/control (Build-Depends): Replace libpcre3-dev with libpcre2-dev. + + -- Yavor Doganov <ya...@gnu.org> Sun, 17 Dec 2023 14:22:39 +0200 + shadowsocks-libev (3.3.5+ds-10) unstable; urgency=medium * Revert the move of systemd service files from /lib/ to /usr/lib/. diff --git a/debian/control b/debian/control index c2becba..d944661 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,7 @@ Build-Depends: libev-dev, libjsonparser-dev, libmbedtls-dev, - libpcre3-dev, + libpcre2-dev, libsodium-dev, pkg-config, xmlto, diff --git a/debian/patches/pcre2.patch b/debian/patches/pcre2.patch new file mode 100644 index 0000000..2691534 --- /dev/null +++ b/debian/patches/pcre2.patch @@ -0,0 +1,157 @@ +Description: Port to PCRE2. +Bug-Debian: https://bugs.debian.org/999965 +Author: Yavor Doganov <ya...@gnu.org> +Forwarded: no +Last-Update: 2023-12-17 +--- + +--- shadowsocks-libev.orig/src/rule.c ++++ shadowsocks-libev/src/rule.c +@@ -78,14 +78,18 @@ + init_rule(rule_t *rule) + { + if (rule->pattern_re == NULL) { +- const char *reerr; +- int reerroffset; ++ int reerr; ++ PCRE2_SIZE reerroffset; + + rule->pattern_re = +- pcre_compile(rule->pattern, 0, &reerr, &reerroffset, NULL); ++ pcre2_compile((PCRE2_SPTR)rule->pattern, strlen(rule->pattern), ++ 0, &reerr, &reerroffset, NULL); + if (rule->pattern_re == NULL) { +- LOGE("Regex compilation of \"%s\" failed: %s, offset %d", +- rule->pattern, reerr, reerroffset); ++ PCRE2_UCHAR buf[120]; ++ ++ pcre2_get_error_message(reerr, buf, sizeof(buf)); ++ LOGE("Regex compilation of \"%s\" failed: %s, offset %zu", ++ rule->pattern, buf, reerroffset); + return 0; + } + } +@@ -97,6 +101,7 @@ + lookup_rule(const struct cork_dllist *rules, const char *name, size_t name_len) + { + struct cork_dllist_item *curr, *next; ++ pcre2_match_data *md = NULL; + + if (name == NULL) { + name = ""; +@@ -105,10 +110,15 @@ + + cork_dllist_foreach_void(rules, curr, next) { + rule_t *rule = cork_container_of(curr, rule_t, entries); +- if (pcre_exec(rule->pattern_re, NULL, +- name, name_len, 0, 0, NULL, 0) >= 0) ++ pcre2_match_data_free(md); ++ md = pcre2_match_data_create_from_pattern(rule->pattern_re, NULL); ++ if (pcre2_match(rule->pattern_re, (PCRE2_SPTR)name, ++ name_len, 0, 0, md, NULL) >= 0) { ++ pcre2_match_data_free(md); + return rule; ++ } + } ++ pcre2_match_data_free(md); + + return NULL; + } +@@ -128,6 +138,6 @@ + + ss_free(rule->pattern); + if (rule->pattern_re != NULL) +- pcre_free(rule->pattern_re); ++ pcre2_code_free(rule->pattern_re); + ss_free(rule); + } +--- shadowsocks-libev.orig/src/rule.h ++++ shadowsocks-libev/src/rule.h +@@ -33,17 +33,16 @@ + + #include <libcork/ds.h> + +-#ifdef HAVE_PCRE_H +-#include <pcre.h> +-#elif HAVE_PCRE_PCRE_H +-#include <pcre/pcre.h> ++#ifdef HAVE_PCRE2_H ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include <pcre2.h> + #endif + + typedef struct rule { + char *pattern; + + /* Runtime fields */ +- pcre *pattern_re; ++ pcre2_code *pattern_re; + + struct cork_dllist_item entries; + } rule_t; +--- shadowsocks-libev.orig/m4/pcre.m4 ++++ shadowsocks-libev/m4/pcre.m4 +@@ -82,12 +82,12 @@ + fi + ], + [ +- AC_CHECK_PROG(PCRE_CONFIG, pcre-config, pcre-config) ++ AC_CHECK_PROG(PCRE_CONFIG, pcre2-config, pcre2-config) + if test "x$PCRE_CONFIG" != "x"; then + enable_pcre=yes + pcre_base_dir="`$PCRE_CONFIG --prefix`" + pcre_include="`$PCRE_CONFIG --cflags | sed -es/-I//`" +- pcre_ldflags="`$PCRE_CONFIG --libs | sed -es/-lpcre// -es/-L//`" ++ pcre_ldflags="`$PCRE_CONFIG --libs8 | sed -es/-lpcre// -es/-L//`" + fi + ]) + +@@ -95,7 +95,7 @@ + AC_MSG_CHECKING([for pcre location]) + AC_CACHE_VAL(ats_cv_pcre_dir,[ + for dir in /usr/local /usr ; do +- if test -d $dir && ( test -f $dir/include/pcre.h || test -f $dir/include/pcre/pcre.h ); then ++ if test -d $dir && ( test -f $dir/include/pcre2.h ); then + ats_cv_pcre_dir=$dir + break + fi +@@ -113,7 +113,7 @@ + fi + else + AC_MSG_CHECKING(for pcre headers in $pcre_include) +- if test -d $pcre_include && test -d $pcre_ldflags && ( test -f $pcre_include/pcre.h || test -f $pcre_include/pcre/pcre.h ); then ++ if test -d $pcre_include && test -d $pcre_ldflags && ( test -f $pcre_include/pcre2.h ); then + AC_MSG_RESULT([ok]) + else + AC_MSG_RESULT([not found]) +@@ -133,14 +133,26 @@ + TS_ADDTO(LDFLAGS, [-L${pcre_ldflags}]) + TS_ADDTO_RPATH(${pcre_ldflags}) + fi +- AC_SEARCH_LIBS([pcre_exec], [pcre], [pcre_have_libs=1]) ++ orig_libs="$LIBS" ++ LIBS="$LIBS -lpcre2-8" ++ AC_MSG_CHECKING([for pcre library]) ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([[#define PCRE2_CODE_UNIT_WIDTH 8 ++#include <pcre2.h> ++]], ++[[pcre2_match_data *md = pcre2_match_data_create(4, NULL);]])], ++ [pcre_have_libs=1 ++ AC_MSG_RESULT([yes])], ++ [LIBS="$orig_libs" ++ AC_MSG_RESULT([no])]) + if test "$pcre_have_libs" != "0"; then +- AC_CHECK_HEADERS(pcre.h, [pcre_have_headers=1]) +- AC_CHECK_HEADERS(pcre/pcre.h, [pcre_have_headers=1]) ++ AC_CHECK_HEADERS([pcre2.h], [pcre_have_headers=1], [], ++ [[#define PCRE2_CODE_UNIT_WIDTH 8 ++ ]]) + fi + if test "$pcre_have_headers" != "0"; then + AC_DEFINE(HAVE_LIBPCRE,1,[Compiling with pcre support]) +- AC_SUBST(LIBPCRE, [-lpcre]) ++ AC_SUBST(LIBPCRE, [-lpcre2-8]) + else + enable_pcre=no + CFLAGS=$saved_cppflags diff --git a/debian/patches/series b/debian/patches/series index 79f268d..bb1af04 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -18,3 +18,4 @@ backport/16-fix-maybe-uninitialized-errors.patch backport/18-Fix-mptcp-on-kernels-with-mainlined-MPTCP.patch backport/19-Redir-UDP-send-back-sockets-should-always-be-IPv6.patch backport/20-Detect-kernel-support-for-MPTCP-at-runtime.patch +pcre2.patch -- 2.43.0