Move haproxy, hyperscan, mc, R, httpd, liblognorm, postfix to pcre2 (#8722)

Co-authored-by: Betty Lakes <bettylakes@microsoft.com>
This commit is contained in:
Betty 2024-04-10 12:47:49 -07:00 коммит произвёл GitHub
Родитель 5fa8d35139
Коммит 01c961af56
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 208 добавлений и 16 удалений

Просмотреть файл

@ -2,7 +2,7 @@
Summary: A language for data analysis and graphics
Name: R
Version: 4.3.2
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2
Vendor: Microsoft Corporation
Distribution: Azure Linux
@ -16,7 +16,6 @@ BuildRequires: gfortran
BuildRequires: glibc-iconv
BuildRequires: make
BuildRequires: msopenjdk-17
BuildRequires: pcre
BuildRequires: pcre2
BuildRequires: pcre2-devel
BuildRequires: readline-devel
@ -118,6 +117,9 @@ TZ="Europe/Paris" make check -k -i
%endif
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 4.3.2-2
- Move from pcre to pcre2
* Tue Feb 13 2024 Rohit Rawat <rohitrawat@microsoft.com> - 4.3.2-1
- Upgrade to 4.3.2

Просмотреть файл

@ -1,7 +1,7 @@
Summary: A fast, reliable HA, load balancing, and proxy solution.
Name: haproxy
Version: 2.9.1
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
Vendor: Microsoft Corporation
Distribution: Azure Linux
@ -10,7 +10,7 @@ URL: https://www.haproxy.org
Source0: https://www.haproxy.org/download/2.9/src/%{name}-%{version}.tar.gz
BuildRequires: lua-devel
BuildRequires: openssl-devel
BuildRequires: pcre-devel
BuildRequires: pcre2-devel
BuildRequires: pkg-config
BuildRequires: systemd-devel
BuildRequires: zlib-devel
@ -32,7 +32,7 @@ Requires: %{name} = %{version}-%{release}
%setup -q
%build
make %{?_smp_mflags} TARGET="linux-glibc" USE_PCRE=1 USE_OPENSSL=1 \
make %{?_smp_mflags} TARGET="linux-glibc" USE_PCRE2=1 USE_OPENSSL=1 \
USE_GETADDRINFO=1 USE_ZLIB=1 USE_SYSTEMD=1
make %{?_smp_mflags} -C admin/systemd
sed -i s/"local\/"/""/g admin/systemd/haproxy.service
@ -59,6 +59,9 @@ install -vDm644 examples/transparent_proxy.cfg %{buildroot}/%{_sysconfdir}/hapr
%{_mandir}/*
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 2.9.1-2
- Move from pcre to pcre2
* Tue Jan 02 2024 Muhammad Falak <mwani@microsoft.com> - 2.9.1-1
- Update version to 2.9.1

Просмотреть файл

@ -3,7 +3,7 @@
Summary: The Apache HTTP Server
Name: httpd
Version: 2.4.58
Release: 1%{?dist}
Release: 2%{?dist}
License: Apache-2.0
Vendor: Microsoft Corporation
Distribution: Azure Linux
@ -42,7 +42,7 @@ BuildRequires: lua-devel
BuildRequires: openldap
BuildRequires: openssl
BuildRequires: openssl-devel
BuildRequires: pcre-devel
BuildRequires: pcre2-devel
BuildRequires: systemd-rpm-macros
Requires: apr-util
@ -50,7 +50,7 @@ Requires: libdb
Requires: lua
Requires: openldap
Requires: openssl
Requires: pcre
Requires: pcre2
Requires(postun): %{_sbindir}/groupdel
Requires(postun): %{_sbindir}/userdel
Requires(pre): %{_sbindir}/groupadd
@ -345,6 +345,9 @@ fi
%{_libexecdir}/httpd-ssl-pass-dialog
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 2.4.58-2
- Move from pcre to pcre2
* Fri Oct 20 2023 Muhammad Falak <mwani@microsoft.com> - 2.4.58-1
- Upgrade version to address CVE-2023-45802, CVE-2023-43622 & CVE-2023-31122

Просмотреть файл

@ -1,7 +1,7 @@
%global __cmake_in_source_build 1
Name: hyperscan
Version: 5.4.2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: High-performance regular expression matching library
License: BSD
Group: Development/Libraries
@ -15,12 +15,12 @@ BuildRequires: libstdc++-devel
BuildRequires: libstdc++
BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: pcre-devel
BuildRequires: pcre2-devel
BuildRequires: python3
BuildRequires: ragel
BuildRequires: sqlite-devel >= 3.0
BuildRequires: libpcap-devel
Requires: pcre
Requires: pcre2
#package requires SSE support and fails to build on non x86_64 archs
ExclusiveArch: x86_64
@ -89,6 +89,9 @@ needed for developing Hyperscan applications.
%{_includedir}/hs/
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 5.4.2-3
- Move from pcre to pcre2
* Tue Feb 13 2024 Andrew Phelps <anphel@microsoft.com> - 5.4.2-2
- Fix build issue with python 3.12 by defining PYTHON_EXECUTABLE

Просмотреть файл

@ -0,0 +1,169 @@
diff --git a/configure.ac b/configure.ac
index b6f92f1..752b7d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,7 @@ AC_ARG_ENABLE(regexp,
)
AM_CONDITIONAL(ENABLE_REGEXP, test x$enable_regexp = xyes)
if test "$enable_regexp" = "yes"; then
- PKG_CHECK_MODULES(PCRE, libpcre)
+ PKG_CHECK_MODULES(PCRE, [libpcre2-8 >= 10.00])
AC_DEFINE(FEATURE_REGEXP, 1, [Regular expressions support enabled.])
FEATURE_REGEXP=1
else
@@ -194,5 +194,4 @@ echo "Testbench enabled: $enable_testbench"
echo "Valgrind enabled: $enable_valgrind"
echo "Debug mode enabled: $enable_debug"
echo "Tools enabled: $enable_tools"
-echo "Docs enabled: $enable_docs"
-
+echo "Docs enabled: $enable_docs"
\ No newline at end of file
diff --git a/src/parser.c b/src/parser.c
index 2d70424..dcd5b4e 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -42,12 +42,6 @@
#include "samp.h"
#include "helpers.h"
-#ifdef FEATURE_REGEXP
-#include <pcre.h>
-#include <errno.h>
-#endif
-
-
/* how should output values be formatted? */
enum FMT_MODE {
FMT_AS_STRING = 0,
diff --git a/src/v1_parser.c b/src/v1_parser.c
index 323ada0..9fb3ccb 100644
--- a/src/v1_parser.c
+++ b/src/v1_parser.c
@@ -39,7 +39,8 @@
#include "v1_samp.h"
#ifdef FEATURE_REGEXP
-#include <pcre.h>
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
#include <errno.h>
#endif
@@ -1266,7 +1267,7 @@ void* tokenized_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
* significantly slower than other field-types.
*/
struct regex_parser_data_s {
- pcre *re;
+ pcre2_code *re;
int consume_group;
int return_group;
int max_groups;
@@ -1276,17 +1277,33 @@ PARSER(Regex)
assert(str != NULL);
assert(offs != NULL);
assert(parsed != NULL);
- unsigned int* ovector = NULL;
+ PCRE2_SIZE *ovector;
+ pcre2_match_data *match_data = NULL;
struct regex_parser_data_s *pData = (struct regex_parser_data_s*) node->parser_data;
if (pData != NULL) {
- ovector = calloc(pData->max_groups, sizeof(unsigned int) * 3);
- if (ovector == NULL) FAIL(LN_NOMEM);
+ match_data = pcre2_match_data_create_from_pattern(pData->re, NULL);
+ if (match_data == NULL) FAIL(LN_NOMEM);
+
+ int result = pcre2_match(
+ pData->re, /* the compiled pattern */
+ (PCRE2_SPTR)str, /* the subject string */
+ (PCRE2_SIZE)strLen, /* the length of the subject */
+ (PCRE2_SIZE)*offs, /* start at offset 0 in the subject */
+ 0, /* default options */
+ match_data, /* block for storing the result */
+ NULL); /* use default match context */
- int result = pcre_exec(pData->re, NULL, str, strLen, *offs, 0, (int*) ovector, pData->max_groups * 3);
if (result == 0) result = pData->max_groups;
if (result > pData->consume_group) {
- /*please check 'man 3 pcreapi' for cryptic '2 * n' and '2 * n + 1' magic*/
+ ovector = pcre2_get_ovector_pointer(match_data);
+ printf("Match succeeded at offset %d\n", (int)ovector[0]);
+
+ /* please check 'man 3 pcre2api' for cryptic '2 * n' and '2 * n + 1' magic
+ * in a nutshell, within the ovector, the first in each pair of values is set to the
+ * offset of the first code unit of a substring, and the second is set to the
+ * offset of the first code unit after the end of a substring.
+ */
if (ovector[2 * pData->consume_group] == *offs) {
*parsed = ovector[2 * pData->consume_group + 1] - ovector[2 * pData->consume_group];
if (pData->consume_group != pData->return_group) {
@@ -1294,22 +1311,20 @@ PARSER(Regex)
if((val = strndup(str + ovector[2 * pData->return_group],
ovector[2 * pData->return_group + 1] -
ovector[2 * pData->return_group])) == NULL) {
- free(ovector);
FAIL(LN_NOMEM);
}
*value = json_object_new_string(val);
free(val);
if (*value == NULL) {
- free(ovector);
FAIL(LN_NOMEM);
}
}
}
}
- free(ovector);
}
r = 0; /* success */
done:
+ pcre2_match_data_free(match_data);
return r;
}
@@ -1346,8 +1361,8 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
char* name = NULL;
struct regex_parser_data_s *pData = NULL;
const char *unescaped_exp = NULL;
- const char *error = NULL;
- int erroffset = 0;
+ PCRE2_SIZE erroffset = 0;
+ int errcode = 0;
CHKN(name = es_str2cstr(node->name, NULL));
@@ -1365,7 +1380,7 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
if ((grp_parse_err = regex_parser_configure_consume_and_return_group(args, pData)) != NULL)
FAIL(LN_BADCONFIG);
- CHKN(pData->re = pcre_compile(exp, 0, &error, &erroffset, NULL));
+ CHKN(pData->re = pcre2_compile((PCRE2_SPTR)exp, PCRE2_ZERO_TERMINATED, 0, &errcode, &erroffset, NULL));
pData->max_groups = ((pData->consume_group > pData->return_group) ? pData->consume_group :
pData->return_group) + 1;
@@ -1387,9 +1402,12 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
ln_dbgprintf(ctx, "couldn't allocate memory for regex-string for field: '%s'", name);
else if (grp_parse_err != NULL)
ln_dbgprintf(ctx, "%s for: '%s'", grp_parse_err, name);
- else if (pData->re == NULL)
+ else if (pData->re == NULL) {
+ PCRE2_UCHAR errbuffer[256];
+ pcre2_get_error_message(errcode, errbuffer, sizeof(errbuffer));
ln_dbgprintf(ctx, "couldn't compile regex(encountered error '%s' at char '%d' in pattern) "
- "for regex-matched field: '%s'", error, erroffset, name);
+ "for regex-matched field: '%s'", errbuffer, (int)erroffset, name);
+ }
regex_parser_data_destructor((void**)&pData);
}
if (exp != NULL) free(exp);
@@ -1401,7 +1419,7 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
void regex_parser_data_destructor(void** dataPtr) {
if ((*dataPtr) != NULL) {
struct regex_parser_data_s *pData = (struct regex_parser_data_s*) *dataPtr;
- if (pData->re != NULL) pcre_free(pData->re);
+ if (pData->re != NULL) pcre2_code_free(pData->re);
free(pData);
*dataPtr = NULL;
}

Просмотреть файл

@ -3,7 +3,7 @@
Summary: Fast samples-based log normalization library
Name: liblognorm
Version: 2.0.6
Release: 3%{?dist}
Release: 4%{?dist}
License: LGPLv2+
Vendor: Microsoft Corporation
Distribution: Azure Linux
@ -13,11 +13,12 @@ BuildRequires: chrpath
BuildRequires: gcc
BuildRequires: libestr-devel
BuildRequires: libfastjson-devel
BuildRequires: pcre-devel
BuildRequires: pcre2-devel
BuildRequires: python3-devel
BuildRequires: python3-sphinx
Patch0: liblognorm-2.0.6-rhbz2105934-sphinx5.patch
Patch1: liblognorm-2.0.6-pcre2.patch
%description
Briefly described, liblognorm is a tool to normalize log data.
@ -58,6 +59,11 @@ log files.
%autosetup -p1
%build
# Prevent rebuild of the configure script.
touch configure aclocal.m4 Makefile.in config.h.in
autoreconf --verbose --force --install
%configure --enable-regexp --enable-docs --docdir=%{htmldir} --includedir=%{_includedir}/%{name}/
%configure \
--enable-regexp \
--enable-docs \
@ -91,6 +97,9 @@ rm %{buildroot}%{htmldir}/{objects.inv,.buildinfo}
%{_bindir}/lognormalizer
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 2.0.6-4
- Move to pcre2 and add patch to support it's usage
* Thu Feb 29 2024 Pawel Winogrodzki <pawelwi@microsoft.com> - 2.0.6-3
- Adding Fedora's Sphinx 5+ patch.

Просмотреть файл

@ -1,7 +1,7 @@
Summary: File manager
Name: mc
Version: 4.8.30
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3+
Vendor: Microsoft Corporation
Distribution: Azure Linux
@ -10,11 +10,11 @@ URL: https://www.midnight-commander.org
Source0: http://ftp.midnight-commander.org/%{name}-%{version}.tar.xz
Patch0: disable-extfs-test.patch
BuildRequires: glib-devel
BuildRequires: pcre-devel
BuildRequires: pcre2-devel
BuildRequires: python3-devel
BuildRequires: slang-devel
Requires: glib
Requires: pcre
Requires: pcre2
Requires: slang
%description
@ -45,6 +45,9 @@ MC (Midnight Commander) is a text-mode full-screen file manager and visual shell
%exclude %{_prefix}/src
%changelog
* Fri Apr 05 2024 Betty Lakes <bettylakes@microsoft.com> - 4.8.30-2
- Move from pcre to pcre2
* Fri Oct 27 2023 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 4.8.30-1
- Auto-upgrade to 4.8.30 - Azure Linux 3.0 - package upgrades