From d9355799d73d75b85175cad69a85be14928bf520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Uhliarik?= Date: Tue, 8 Aug 2017 10:09:14 +0200 Subject: [PATCH 1/4] new version 4.0.21 --- sources | 4 ++-- squid.spec | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sources b/sources index f39bd64..c0f17ad 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (squid-4.0.20.tar.xz) = 8599afb8819cf856ca60c1d292407a4cb172086d971355bec7269f2fa753fcb3d5d2d2e2ec488f273b4131b7eb78c807f6c03ff9124d69b56507044cdbc5e034 -SHA512 (squid-4.0.20.tar.xz.asc) = edca4000a9091a772bdd494cba79e8893f46a14370f97a652634aee91f2d97af4f2898ae16486cec25d8d54ed235b35785eb93d6665291e2b3074194fa08e2cc +SHA512 (squid-4.0.21.tar.xz) = eb0cf99c4a2abb48a2edfbfbd18c963816da28c0cb050a5825d8fea1ce4f4d932ba2c737b47dc34bfbb62bf83ba1e9589b67c3bac1fd8413de81e074fe5d7b7e +SHA512 (squid-4.0.21.tar.xz.asc) = 314bab337ecbf73abb1f0f9df0681b85e48c45122f03771169bcf3227daba4e942635a5b058d642a1dbd86153e442c71b5d7c5bbc1be19d198853bc9d6deea90 diff --git a/squid.spec b/squid.spec index 455da9e..fa7367b 100644 --- a/squid.spec +++ b/squid.spec @@ -1,8 +1,8 @@ %define __perl_requires %{SOURCE98} Name: squid -Version: 4.0.20 -Release: 2%{?dist} +Version: 4.0.21 +Release: 1%{?dist} Summary: The Squid proxy caching server Epoch: 7 # See CREDITS for breakdown of non GPLv2+ code @@ -299,6 +299,9 @@ fi %changelog +* Tue Aug 08 2017 Luboš Uhliarik - 7:4.0.21-1 +- new version 4.0.21 + * Mon Jun 05 2017 Luboš Uhliarik - 7:4.0.20-2 - related: new version 4.0.20 From 7075baab17edac11975b8bd1c61894d16cb1427c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Uhliarik?= Date: Mon, 20 Nov 2017 17:04:52 +0100 Subject: [PATCH 2/4] Resolves: #1481195 - squid loses some REs when optimising ACLs --- squid-4.0.21-large-acl.patch | 116 +++++++++++++++++++++++++++++++++++ squid.spec | 7 ++- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 squid-4.0.21-large-acl.patch diff --git a/squid-4.0.21-large-acl.patch b/squid-4.0.21-large-acl.patch new file mode 100644 index 0000000..0036245 --- /dev/null +++ b/squid-4.0.21-large-acl.patch @@ -0,0 +1,116 @@ +diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc +index 01a4c12..82b2b93 100644 +--- a/src/acl/RegexData.cc ++++ b/src/acl/RegexData.cc +@@ -22,6 +22,7 @@ + #include "ConfigParser.h" + #include "Debug.h" + #include "sbuf/List.h" ++#include "sbuf/Algorithms.h" + + ACLRegexData::~ACLRegexData() + { +@@ -129,6 +130,18 @@ compileRE(std::list &curlist, const char * RE, int flags) + return true; + } + ++static bool ++compileRE(std::list &curlist, const SBufList &RE, int flags) ++{ ++ if (RE.empty()) ++ return curlist.empty(); // XXX: old code did this. It looks wrong. ++ SBuf regexp; ++ static const SBuf openparen("("), closeparen(")"), separator(")|("); ++ JoinContainerIntoSBuf(regexp, RE.begin(), RE.end(), separator, openparen, ++ closeparen); ++ return compileRE(curlist, regexp.c_str(), flags); ++} ++ + /** Compose and compile one large RE from a set of (small) REs. + * The ultimate goal is to have only one RE per ACL so that match() is + * called only once per ACL. +@@ -137,15 +150,12 @@ static int + compileOptimisedREs(std::list &curlist, const SBufList &sl) + { + std::list newlist; +- int numREs = 0; ++ SBufList accumulatedRE; ++ int numREs = 0, reSize = 0; + int flags = REG_EXTENDED | REG_NOSUB; +- int largeREindex = 0; +- char largeRE[BUFSIZ]; +- *largeRE = 0; + + for (const SBuf & configurationLineWord : sl) { +- int RElen; +- RElen = configurationLineWord.length(); ++ const int RElen = configurationLineWord.length(); + + static const SBuf minus_i("-i"); + static const SBuf plus_i("+i"); +@@ -155,10 +165,11 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) + debugs(28, 2, "optimisation of -i ... -i" ); + } else { + debugs(28, 2, "-i" ); +- if (!compileRE(newlist, largeRE, flags)) ++ if (!compileRE(newlist, accumulatedRE, flags)) + return 0; + flags |= REG_ICASE; +- largeRE[largeREindex=0] = '\0'; ++ accumulatedRE.clear(); ++ reSize = 0; + } + } else if (configurationLineWord == plus_i) { + if ((flags & REG_ICASE) == 0) { +@@ -166,37 +177,34 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) + debugs(28, 2, "optimisation of +i ... +i"); + } else { + debugs(28, 2, "+i"); +- if (!compileRE(newlist, largeRE, flags)) ++ if (!compileRE(newlist, accumulatedRE, flags)) + return 0; + flags &= ~REG_ICASE; +- largeRE[largeREindex=0] = '\0'; ++ accumulatedRE.clear(); ++ reSize = 0; + } +- } else if (RElen + largeREindex + 3 < BUFSIZ-1) { ++ } else if (reSize < 1024) { + debugs(28, 2, "adding RE '" << configurationLineWord << "'"); +- if (largeREindex > 0) { +- largeRE[largeREindex] = '|'; +- ++largeREindex; +- } +- largeRE[largeREindex] = '('; +- ++largeREindex; +- configurationLineWord.copy(largeRE+largeREindex, BUFSIZ-largeREindex); +- largeREindex += configurationLineWord.length(); +- largeRE[largeREindex] = ')'; +- ++largeREindex; +- largeRE[largeREindex] = '\0'; ++ accumulatedRE.push_back(configurationLineWord); + ++numREs; ++ reSize += configurationLineWord.length(); + } else { + debugs(28, 2, "buffer full, generating new optimised RE..." ); +- if (!compileRE(newlist, largeRE, flags)) ++ accumulatedRE.push_back(configurationLineWord); ++ if (!compileRE(newlist, accumulatedRE, flags)) + return 0; +- largeRE[largeREindex=0] = '\0'; ++ accumulatedRE.clear(); ++ reSize = 0; + continue; /* do the loop again to add the RE to largeRE */ + } + } + +- if (!compileRE(newlist, largeRE, flags)) ++ if (!compileRE(newlist, accumulatedRE, flags)) + return 0; + ++ accumulatedRE.clear(); ++ reSize = 0; ++ + /* all was successful, so put the new list at the tail */ + curlist.splice(curlist.end(), newlist); + diff --git a/squid.spec b/squid.spec index fa7367b..e27a667 100644 --- a/squid.spec +++ b/squid.spec @@ -2,7 +2,7 @@ Name: squid Version: 4.0.21 -Release: 1%{?dist} +Release: 2%{?dist} Summary: The Squid proxy caching server Epoch: 7 # See CREDITS for breakdown of non GPLv2+ code @@ -31,6 +31,7 @@ Patch201: squid-4.0.11-config.patch Patch202: squid-3.1.0.9-location.patch Patch203: squid-3.0.STABLE1-perlpath.patch Patch204: squid-3.5.9-include-guards.patch +Patch205: squid-4.0.21-large-acl.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: bash >= 2.0 @@ -91,6 +92,7 @@ lookup program (dnsserver), a program for retrieving FTP data %patch202 -p1 -b .location %patch203 -p1 -b .perlpath %patch204 -p0 -b .include-guards +%patch205 -p1 -b .large_acl %build # cppunit-config patch changes configure.ac @@ -299,6 +301,9 @@ fi %changelog +* Mon Nov 20 2017 Luboš Uhliarik - 7:4.0.21-2 +- Resolves: #1481195 - squid loses some REs when optimising ACLs + * Tue Aug 08 2017 Luboš Uhliarik - 7:4.0.21-1 - new version 4.0.21 From 3080fc6d6f24431353d8f279f266d810c21f7614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Uhliarik?= Date: Mon, 20 Nov 2017 17:36:52 +0100 Subject: [PATCH 3/4] Resolves: #1481195 - squid loses some REs when optimising ACLs --- squid-4.0.21-large-acl.patch | 74 +++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/squid-4.0.21-large-acl.patch b/squid-4.0.21-large-acl.patch index 0036245..8aacf38 100644 --- a/squid-4.0.21-large-acl.patch +++ b/squid-4.0.21-large-acl.patch @@ -1,5 +1,5 @@ diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc -index 01a4c12..82b2b93 100644 +index 01a4c12..b5c1679 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -22,6 +22,7 @@ @@ -29,7 +29,7 @@ index 01a4c12..82b2b93 100644 /** Compose and compile one large RE from a set of (small) REs. * The ultimate goal is to have only one RE per ACL so that match() is * called only once per ACL. -@@ -137,15 +150,12 @@ static int +@@ -137,16 +150,11 @@ static int compileOptimisedREs(std::list &curlist, const SBufList &sl) { std::list newlist; @@ -44,11 +44,11 @@ index 01a4c12..82b2b93 100644 for (const SBuf & configurationLineWord : sl) { - int RElen; - RElen = configurationLineWord.length(); -+ const int RElen = configurationLineWord.length(); - +- static const SBuf minus_i("-i"); static const SBuf plus_i("+i"); -@@ -155,10 +165,11 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) + if (configurationLineWord == minus_i) { +@@ -155,10 +163,11 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) debugs(28, 2, "optimisation of -i ... -i" ); } else { debugs(28, 2, "-i" ); @@ -62,7 +62,7 @@ index 01a4c12..82b2b93 100644 } } else if (configurationLineWord == plus_i) { if ((flags & REG_ICASE) == 0) { -@@ -166,37 +177,34 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) +@@ -166,37 +175,34 @@ compileOptimisedREs(std::list &curlist, const SBufList &sl) debugs(28, 2, "optimisation of +i ... +i"); } else { debugs(28, 2, "+i"); @@ -114,3 +114,65 @@ index 01a4c12..82b2b93 100644 /* all was successful, so put the new list at the tail */ curlist.splice(curlist.end(), newlist); +diff --git a/src/sbuf/Algorithms.h b/src/sbuf/Algorithms.h +index 21ee889..338e9c0 100644 +--- a/src/sbuf/Algorithms.h ++++ b/src/sbuf/Algorithms.h +@@ -81,6 +81,57 @@ SBufContainerJoin(const Container &items, const SBuf& separator) + return rv; + } + ++/** Join container of SBufs and append to supplied target ++ * ++ * append to the target SBuf all elements in the [begin,end) range from ++ * an iterable container, prefixed by prefix, separated by separator and ++ * followed by suffix. Prefix and suffix are added also in case of empty ++ * iterable ++ * ++ * \return the modified dest ++ */ ++template ++SBuf& ++JoinContainerIntoSBuf(SBuf &dest, const ContainerIterator &begin, ++ const ContainerIterator &end, const SBuf& separator, ++ const SBuf& prefix = SBuf(), const SBuf& suffix = SBuf()) ++{ ++ if (begin == end) { ++ dest.append(prefix).append(suffix); ++ return dest; ++ } ++ ++ // optimization: pre-calculate needed storage ++ const SBuf::size_type totalContainerSize = ++ std::accumulate(begin, end, 0, SBufAddLength(separator)) + ++ dest.length() + prefix.length() + suffix.length(); ++ SBufReservationRequirements req; ++ req.minSpace = totalContainerSize; ++ dest.reserve(req); ++ ++ auto i = begin; ++ dest.append(prefix); ++ dest.append(*i); ++ ++i; ++ for (; i != end; ++i) ++ dest.append(separator).append(*i); ++ dest.append(suffix); ++ return dest; ++} ++ ++ ++/// convenience wrapper of JoinContainerIntoSBuf with no caller-supplied SBuf ++template ++SBuf ++JoinContainerToSBuf(const ContainerIterator &begin, ++ const ContainerIterator &end, const SBuf& separator, ++ const SBuf& prefix = SBuf(), const SBuf& suffix = SBuf()) ++{ ++ SBuf rv; ++ return JoinContainerIntoSBuf(rv, begin, end, separator, prefix, suffix); ++} ++ ++ + namespace std { + /// default hash functor to support std::unordered_map + template <> From 1951e3cb10bef2c4f6e934ba5c05912599200412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Uhliarik?= Date: Tue, 23 Jan 2018 17:00:16 +0100 Subject: [PATCH 4/4] new version 4.0.23 --- sources | 4 ++-- squid-3.0.STABLE1-perlpath.patch | 9 +++++---- squid.spec | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sources b/sources index c0f17ad..15e2a74 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (squid-4.0.21.tar.xz) = eb0cf99c4a2abb48a2edfbfbd18c963816da28c0cb050a5825d8fea1ce4f4d932ba2c737b47dc34bfbb62bf83ba1e9589b67c3bac1fd8413de81e074fe5d7b7e -SHA512 (squid-4.0.21.tar.xz.asc) = 314bab337ecbf73abb1f0f9df0681b85e48c45122f03771169bcf3227daba4e942635a5b058d642a1dbd86153e442c71b5d7c5bbc1be19d198853bc9d6deea90 +SHA512 (squid-4.0.23.tar.xz) = 30d59f7ec8effae53603d7e33536baa27a523b34f8865463cb4d7c8496f485e53dd21d1cb40cda52963d29cffad70dc95f314c6c204085beb7f3a91266b3c72a +SHA512 (squid-4.0.23.tar.xz.asc) = c6e524221dd2e4987cd35c23e0a28ee1736e5fffb8f7edd0d2b3ddec8dcd8a330c34ea798ae77356bb8c5c16a7a9942775612e9d3b37cd880fbd9ead67ccdd10 diff --git a/squid-3.0.STABLE1-perlpath.patch b/squid-3.0.STABLE1-perlpath.patch index dda0d33..052b8d7 100644 --- a/squid-3.0.STABLE1-perlpath.patch +++ b/squid-3.0.STABLE1-perlpath.patch @@ -1,9 +1,10 @@ -diff -up squid-3.0.STABLE1/contrib/url-normalizer.pl.perlpath squid-3.0.STABLE1/contrib/url-normalizer.pl ---- squid-3.0.STABLE1/contrib/url-normalizer.pl.perlpath 1996-12-06 18:54:31.000000000 +0100 -+++ squid-3.0.STABLE1/contrib/url-normalizer.pl 2008-01-23 12:07:50.000000000 +0100 +diff --git a/contrib/url-normalizer.pl b/contrib/url-normalizer.pl +index 90ac6a4..8dbed90 100755 +--- a/contrib/url-normalizer.pl ++++ b/contrib/url-normalizer.pl @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl -Tw +#!/usr/bin/perl -Tw # - # * Copyright (C) 1996-2017 The Squid Software Foundation and contributors + # * Copyright (C) 1996-2018 The Squid Software Foundation and contributors # * diff --git a/squid.spec b/squid.spec index e27a667..8a10b0d 100644 --- a/squid.spec +++ b/squid.spec @@ -1,8 +1,8 @@ %define __perl_requires %{SOURCE98} Name: squid -Version: 4.0.21 -Release: 2%{?dist} +Version: 4.0.23 +Release: 1%{?dist} Summary: The Squid proxy caching server Epoch: 7 # See CREDITS for breakdown of non GPLv2+ code @@ -301,6 +301,9 @@ fi %changelog +* Tue Jan 23 2018 Luboš Uhliarik - 7:4.0.23-1 +- new version 4.0.23 + * Mon Nov 20 2017 Luboš Uhliarik - 7:4.0.21-2 - Resolves: #1481195 - squid loses some REs when optimising ACLs