]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
21 months agoFix infinite recursion when parsing HTTP chunks (#1553)
Alex Rousskov [Tue, 31 Oct 2023 11:35:02 +0000 (11:35 +0000)] 
Fix infinite recursion when parsing HTTP chunks (#1553)

This change stops infinite HttpStateData recursion with at-max-capacity
inBuf. Such inBuf prevents progress in the following call chain:

* processReply()
* processReplyBody() and decodeAndWriteReplyBody()
* maybeReadVirginBody()
* maybeMakeSpaceAvailable() -- tries but fails to quit processing
* processReply()

HttpStateData::maybeMakeSpaceAvailable() no longer calls processReply(),
preventing recursion.

maybeReadVirginBody() now aborts transactions that would otherwise get
stalled due to full read buffer at its maximum capacity. This change
requires that all maybeReadVirginBody() callers do actually need more
response data to make progress. AFAICT, that (natural) invariant holds.

We moved transaction stalling check from maybeMakeSpaceAvailable() into
its previous callers. Without that move, maybeMakeSpaceAvailable() would
have to handle both abortTransaction() and delayRead() cases. Besides
increased code complexity, that would trigger some premature delayRead()
calls (at maybeReadVirginBody() time). Deciding whether to delay socket
reads is complicated, the delay mechanism is expensive, and delaying may
become unnecessary by the time the socket becomes readable, so it is
best to continue to only delayRead() at readReply() time, when there is
no other choice left.

maybeReadVirginBody() mishandled cases where progress was possible, but
not _immediately_ -- it did nothing in those cases, probably stalling
transactions when maybeMakeSpaceAvailable() returned false but did not
call processReply(). This is now fixed: maybeReadVirginBody() now starts
waiting for the socket to be ready for reading in those cases,
effectively passing control to readReply() that handles them.

maybeReadVirginBody() prematurely grew buffer for future socket reads.
As a (positive) side effect of the above refactoring, we now delay
buffer growth until the actual read(2) time, which is best for
performance. Most likely, this premature buffer growth was an accident:
maybeReadVirginBody() correctly called maybeMakeSpaceAvailable() with
doGrow set to false. However, maybeMakeSpaceAvailable() misinterpreted
doGrow as a "do not actually do it" parameter. That bug is now gone.

This recursion bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/
where it was filed as "Chunked Encoding Stack Overflow".

21 months agoRemove unnecessary SquidString include in Uri.cc (#1559)
Francesco Chemolli [Mon, 30 Oct 2023 16:56:20 +0000 (16:56 +0000)] 
Remove unnecessary SquidString include in Uri.cc (#1559)

21 months agoDocs: fix some spelling in ChangeLog (#1550)
Khalid Abdullah [Sun, 29 Oct 2023 22:43:08 +0000 (22:43 +0000)] 
Docs: fix some spelling in ChangeLog (#1550)

21 months agoRemove cachemgr.cgi tool (#1542)
Amos Jeffries [Sun, 29 Oct 2023 19:17:22 +0000 (19:17 +0000)] 
Remove cachemgr.cgi tool (#1542)

21 months agoDocs: update cfgman tarball automation (#1546)
Amos Jeffries [Sun, 29 Oct 2023 04:12:46 +0000 (04:12 +0000)] 
Docs: update cfgman tarball automation (#1546)

Fix script issues:

    NOTICE: unknown line 'IF ...'
    NOTICE: unknown line 'ENDIF'
    NOTICE: unknown line 'POSTSCRIPTUM: ...'

Add display of which cf.data.pre line each such NOTICE
(and some debugs) was found on.

Add missing HAVE_AUTH_* definitions.

Fix case typo of if/endif so regex can detect it.

Also, fix indentation typo in 'acl' directive texts.

21 months agoRemove disabled classful networks code (#1547)
Francesco Chemolli [Sat, 28 Oct 2023 01:33:24 +0000 (01:33 +0000)] 
Remove disabled classful networks code (#1547)

Removed ifdef-d code in networkFromInaddr() and mark that function as
static. The code was disabled since 1997 commit 429fdbe.

21 months agoExit without asserting when helper process startup fails (#1543)
Alex Rousskov [Fri, 27 Oct 2023 21:27:20 +0000 (21:27 +0000)] 
Exit without asserting when helper process startup fails (#1543)

... to dup() after fork() and before execvp().

Assertions are for handling program logic errors. Helper initialization
code already handled system call errors correctly (i.e. by exiting the
newly created helper process with an error), except for a couple of
assert()s that could be triggered by dup(2) failures.

This bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/ipc-assert.html
where it was filed as 'Assertion in Squid "Helper" Process Creator'.

21 months agoDo not double-check cbdataReferenceDone() argument (#1537)
Francesco Chemolli [Fri, 27 Oct 2023 16:11:34 +0000 (16:11 +0000)] 
Do not double-check cbdataReferenceDone() argument (#1537)

cbdataReferenceDone internally checks that the argument is not null.
Remove duplicate check from all callsites that have it

21 months agoRemove tool 'purge' for management of UFS/AUFS/DiskD caches (#1541)
Amos Jeffries [Fri, 27 Oct 2023 07:47:26 +0000 (07:47 +0000)] 
Remove tool 'purge' for management of UFS/AUFS/DiskD caches (#1541)

21 months agoFix test suite: actually run it (#1539)
Francesco Chemolli [Thu, 26 Oct 2023 17:48:30 +0000 (17:48 +0000)] 
Fix test suite: actually run it (#1539)

Fix a bug introduced by commit a7b75c6498, where unit tests
would be built but not actually run.

21 months agoRFC 1123: Fix date parsing (#1538)
Alex Rousskov [Wed, 25 Oct 2023 19:41:45 +0000 (19:41 +0000)] 
RFC 1123: Fix date parsing (#1538)

The bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/datetime-overflow.html
where it was filed as "1-Byte Buffer OverRead in RFC 1123 date/time
Handling".

21 months agoImprove handling of expanding HTTP header values (#1536)
Alex Rousskov [Wed, 25 Oct 2023 11:47:19 +0000 (11:47 +0000)] 
Improve handling of expanding HTTP header values (#1536)

Squid manipulations often increase HTTP header value length compared to
the corresponding raw value received by Squid. Raw header length is
checked against request_header_max_size and reply_header_max_size that
default to 64KB, making the raw value safe to store in a String object
(by default). However, when the increased length of a manipulated value
exceeds String class limits, Squid leaks memory, asserts, or possibly
stalls affected transactions. The long-term fix for this problem is a
complete String elimination from Squid sources, but that takes time.

Known manipulations may effectively concatenate headers and/or increase
header value length by 50%. This workaround makes such known increases
safe by essentially tripling String class limits:

    (64KB + 64KB) * 150% = 3 * 64KB

This bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/response-memleaks.html
where it was filed as "Memory Leak in HTTP Response Parsing".

21 months agoFix build on MacOS (#1535)
Francesco Chemolli [Wed, 25 Oct 2023 00:27:18 +0000 (00:27 +0000)] 
Fix build on MacOS (#1535)

To use std::nullptr_t it is necessary to include <cstddef>
on MacOS Ventura 13.4.1
with clang version 14.0.3 (Xcode 14.3.1)

21 months agoMaintenance: consolidate testBoilerpate header file (#1534)
Francesco Chemolli [Mon, 23 Oct 2023 14:28:50 +0000 (14:28 +0000)] 
Maintenance: consolidate testBoilerpate header file (#1534)

21 months agoRemove squidclient (#1514)
Francesco Chemolli [Sat, 21 Oct 2023 09:38:56 +0000 (09:38 +0000)] 
Remove squidclient (#1514)

Since recent commit a4e35bd removed cache_object support, popular
clients like wget and curl can do everything squidclient can, with one
exception: They cannot expand `mgr:foo` macros into
`http://localhost:3128/squid-internal-mgr/foo` URLs. That single feature
is easily emulated and not worth keeping (fairly heavy) squidclient for,
especially since recent Squid security improvements often require
customizing squidclient commands with more and more options (to address
problems tracked in Squid bug 5283).

21 months agonegotiate_wrapper_auth: protect from responses over 64KB (#1530)
Alex Rousskov [Fri, 20 Oct 2023 22:24:45 +0000 (22:24 +0000)] 
negotiate_wrapper_auth: protect from responses over 64KB (#1530)

... received from NTLM and Kerberos helpers.

This code uses MAX_AUTHTOKEN_LEN (~64KB) buffers to read response lines.
fgets(3) guarantees to terminate the supplied buffer, but it does not
return nil when the input line is larger than the buffer. We have
already detected such "Oversized message" cases for fgets(stdin) calls,
but not for fgets(FDNOUT) and fgets(FDKOUT) calls.

21 months agoMaintenance: reduce output of CONTRIBUTORS update script (#1527)
Amos Jeffries [Thu, 19 Oct 2023 12:24:08 +0000 (12:24 +0000)] 
Maintenance: reduce output of CONTRIBUTORS update script (#1527)

Reduce output to brief summary of actual changes (if any).

Add --quiet to completely silence all non-error output.

Add --verbose for extra information. May be repeated.

21 months agoFix "overriding recipe" gmake warnings in src/html/Makefile.am (#1528)
Alex Rousskov [Thu, 19 Oct 2023 02:34:28 +0000 (02:34 +0000)] 
Fix "overriding recipe" gmake warnings in src/html/Makefile.am (#1528)

    Makefile:1254: warning: overriding recipe for target 'testHeaders'
    Makefile:1233: warning: ignoring old recipe for target 'testHeaders'
    Makefile:1257: warning: overriding recipe for target '.h.hdrtest'
    Makefile:1236: warning: ignoring old recipe for target '.h.hdrtest'

Makefile.am included a second TestHeaders.am since inception in recent
commit 1d0bc8e: Common.am already includes TestHeaders.am.

21 months agoUpdate ChangeLog for upcoming v6.4 (#1524)
Francesco Chemolli [Wed, 18 Oct 2023 17:52:58 +0000 (17:52 +0000)] 
Update ChangeLog for upcoming v6.4 (#1524)

21 months agoFix validation of certificates with CN=* (#1523)
Andreas Weigel [Wed, 18 Oct 2023 04:14:31 +0000 (04:14 +0000)] 
Fix validation of certificates with CN=* (#1523)

The bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/
where it was filed as "Buffer UnderRead in SSL CN Parsing".

21 months agoAdd libhtml.la for HTML syntax tools (#1306)
Amos Jeffries [Tue, 17 Oct 2023 20:36:05 +0000 (20:36 +0000)] 
Add libhtml.la for HTML syntax tools (#1306)

21 months agoRemove unused HttpHeaderFieldInfo class (#1515)
Francesco Chemolli [Sun, 15 Oct 2023 20:50:14 +0000 (20:50 +0000)] 
Remove unused HttpHeaderFieldInfo class (#1515)

21 months agoFix stack buffer overflow when parsing Digest Authorization (#1517)
Alex Bason [Sun, 15 Oct 2023 13:04:47 +0000 (13:04 +0000)] 
Fix stack buffer overflow when parsing Digest Authorization (#1517)

The bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/digest-overflow.html
where it was filed as "Stack Buffer Overflow in Digest Authentication".

21 months agoUpgrade AsList separators to support c-strings (#1519)
Francesco Chemolli [Sun, 15 Oct 2023 04:08:29 +0000 (04:08 +0000)] 
Upgrade AsList separators to support c-strings (#1519)

21 months agoRFC 9112: Improve HTTP chunked encoding compliance (#1498)
Amos Jeffries [Fri, 13 Oct 2023 08:44:16 +0000 (08:44 +0000)] 
RFC 9112: Improve HTTP chunked encoding compliance (#1498)

21 months agoSquid version 3.4 (and older) End-Of-Life (#1507)
Amos Jeffries [Thu, 12 Oct 2023 18:11:23 +0000 (18:11 +0000)] 
Squid version 3.4 (and older) End-Of-Life (#1507)

We are about to hit the 10 year anniversary of v3.4
release. With all known downstream OS vendors now
distributing at least Squid version 3.5.

21 months agoUpdate ChangeLog for upcoming v6.4 (#1510)
Francesco Chemolli [Thu, 12 Oct 2023 08:32:07 +0000 (08:32 +0000)] 
Update ChangeLog for upcoming v6.4 (#1510)

21 months agoRecognize internal requests created by adaptation/redirection (#1504)
Eduard Bagdasaryan [Tue, 10 Oct 2023 22:42:06 +0000 (22:42 +0000)] 
Recognize internal requests created by adaptation/redirection (#1504)

Before this fix, Squid set flags.internal for virgin requests but not
for adapted/redirected requests, leaving post-adaptation request
processing code in an inconsistent state, forwarding the
internalCheck()-compliant adapted/redirected requests as regular
requests, triggering forwarding loops and complicating code refactoring.

21 months agoFix handling of zero cache_peers with --enable-cache-digests (#1502)
Eduard Bagdasaryan [Mon, 9 Oct 2023 23:57:11 +0000 (23:57 +0000)] 
Fix handling of zero cache_peers with --enable-cache-digests (#1502)

The bug was introduced in recent commit 2e24d0b.

21 months agoPrep for 6.4 (#1503)
Amos Jeffries [Mon, 9 Oct 2023 20:40:03 +0000 (20:40 +0000)] 
Prep for 6.4 (#1503)

21 months agoRewrite SplayNode to eliminate recursive calls (#1431)
Martin Grimm [Mon, 9 Oct 2023 17:10:43 +0000 (17:10 +0000)] 
Rewrite SplayNode to eliminate recursive calls (#1431)

Recursive method calls in SplayNode can lead to a stack overflow with
large (degenerate) trees, e.g. after creating a large dst acl from a
sorted ip list.

21 months agoUpgrade ACLFilledChecklist::request to smart Pointer (#1501)
Amos Jeffries [Sun, 8 Oct 2023 20:23:17 +0000 (20:23 +0000)] 
Upgrade ACLFilledChecklist::request to smart Pointer (#1501)

No logic changes. Just the member type.

21 months agoMaintenance: use SBufs for ErrorDetailEntry data fields (#1451)
Francesco Chemolli [Fri, 6 Oct 2023 15:11:30 +0000 (15:11 +0000)] 
Maintenance: use SBufs for ErrorDetailEntry data fields (#1451)

Also fixed (re)configuration crashes when an error-details.txt entry is
missing a required "detail" or "descr" field.

21 months agoFix "make check" to test headers (#1463)
Francesco Chemolli [Tue, 3 Oct 2023 22:38:02 +0000 (22:38 +0000)] 
Fix "make check" to test headers (#1463)

A "make check" testHeaders target is supposed to check that C/C++ header
files can be compiled "autonomously" (i.e. without any other code except
the required squid.h). Since 2010 commit a0fdc9b, existing testHeaders
were not detecting problems in any headers due to a use of a shell
heredoc with echo, a command that does not read from standard input.

This fix ensures that all C/C++ header files used by "make" are tested
in the corresponding "make check".

This change also improves parallel testing of individual header files.

21 months agoY2038: improve printing of time settings (#1493)
Francesco Chemolli [Tue, 3 Oct 2023 18:11:51 +0000 (18:11 +0000)] 
Y2038: improve printing of time settings (#1493)

Avoid truncation errors when printing time_t-based squid.conf directives
on platforms with 32-bit int and 64-bit time_t. Also avoid similar
errors when printing time_msec-based directives on platforms with 32-bit
int.

Detected by Coverity. CID 1529622: Use of 32-bit time_t (Y2K38_SAFETY).

21 months agoFix handling of zero cache_peers (#1499)
Eduard Bagdasaryan [Tue, 3 Oct 2023 14:40:02 +0000 (14:40 +0000)] 
Fix handling of zero cache_peers (#1499)

The bug was introduced in recent commit 2e24d0b.

21 months agoY2038: Fix cache_peer connect-timeout reporting (#1494)
Francesco Chemolli [Tue, 3 Oct 2023 08:03:39 +0000 (08:03 +0000)] 
Y2038: Fix cache_peer connect-timeout reporting (#1494)

... on systems with 64-bit time_t and 32-bit int.

Also fixed `htcp=oldsquid` reporting broken since 2015 commit 4ac1880.

This fix affects mgr:config and mgr:server_list cache manager reports.

21 months agoReduce helper callback code duplication (#1490)
Eduard Bagdasaryan [Mon, 2 Oct 2023 23:05:30 +0000 (23:05 +0000)] 
Reduce helper callback code duplication (#1490)

No Squid functionality changes are expected.

22 months agoConverted helperOpenServers() to a virtual Helper::Client member (#1489)
Eduard Bagdasaryan [Thu, 28 Sep 2023 18:00:59 +0000 (18:00 +0000)] 
Converted helperOpenServers() to a virtual Helper::Client member (#1489)

addressing a TODO.

No Squid functionality changes are expected.

22 months agoDo not use raw pointers to index userhash CachePeers (#1496)
Eduard Bagdasaryan [Wed, 27 Sep 2023 01:03:21 +0000 (01:03 +0000)] 
Do not use raw pointers to index userhash CachePeers (#1496)

Simplified and improved code safety by using CbcPointers for userhash
cache_peers, as we have done for CARP peers in recent commit e7959b5.

Also fixed mgr:userehash Cache Manager reports to detail relevant
cache_peers instead of all cache_peers. This problem existed since
inception (2008 commit f7e1d9c) as detailed in recent commit e7959b5.

22 months agoY2038: Use time_t for commSetConnTimeout() timeout parameter (#1492)
Francesco Chemolli [Tue, 26 Sep 2023 09:56:54 +0000 (09:56 +0000)] 
Y2038: Use time_t for commSetConnTimeout() timeout parameter (#1492)

Change commSetConnTimeout() "timeout" parameter from int to time_t, to
match the common caller type and improve Year 2038-safety on systems
with 32-bit int.

Detected by Coverity. CID 1545129: Use of 32-bit time_t (Y2K38_SAFETY).

22 months agoKill helpers that speak without being spoken to (#1488)
Eduard Bagdasaryan [Sat, 23 Sep 2023 18:51:05 +0000 (18:51 +0000)] 
Kill helpers that speak without being spoken to (#1488)

    ERROR: helperHandleRead: unexpected read from ...
    ERROR: helperStatefulHandleRead: unexpected read from ...

Squid ignored bytes received from both stateful and stateless helper
processes that had no outstanding helper requests at the time of
read(2). In stateful helpers, the implementation also resulted in
undefined behavior: Calling std::list::front() with an empty list.
Ignoring these "early" bytes also complicates code improvements.

Detecting early bytes cannot be done reliably because Squid cannot know
whether some early bytes were sent just before Squid created a helper
request and, hence, could be mistaken for a helper response to that
request. Incorrectly mapping helper responses could lead to serious
problems. When Squid is lucky to detect a buggy helper that sends early
bytes, the safest and simplest action is to kill the helper process.

22 months agotestheaders.sh: force-remove temporary files (#1487)
Francesco Chemolli [Sat, 23 Sep 2023 16:16:42 +0000 (16:16 +0000)] 
testheaders.sh: force-remove temporary files (#1487)

At high levels of build parallelism on systems using GNU coreutils,
sometimes "make check" hangs on a request to confirm
removal of a read-only file temporary file.

Force-remove temporary test files to ensure removal is noniteractive.

22 months agoDo not use raw pointers to index sourcehash CachePeers (#1474)
Eduard Bagdasaryan [Sat, 23 Sep 2023 03:57:01 +0000 (03:57 +0000)] 
Do not use raw pointers to index sourcehash CachePeers (#1474)

Simplified and improved code safety by using CbcPointers for sourcehash
cache_peers, as we have done for CARP peers in recent commit e7959b5.

Also fixed mgr:sourcehash Cache Manager reports to detail relevant
cache_peers instead of all cache_peers. This problem existed since
inception (2008 commit f7e1d9c) as detailed in recent commit e7959b5.

Also applied the new "no new globals" policy to CARP peering code, to
keep improved CARP and sourcehash peering code in sync.

22 months agoMaintenance: delete empty comm_poll.h (#1484)
Francesco Chemolli [Fri, 22 Sep 2023 19:59:37 +0000 (19:59 +0000)] 
Maintenance: delete empty comm_poll.h (#1484)

Unused since 2011 commit d841c88.
Empty since 2008 commit 5acc9f3.

22 months agoBug 5300: cachemgr.cgi assertion (#1478)
Amos Jeffries [Thu, 21 Sep 2023 17:09:34 +0000 (17:09 +0000)] 
Bug 5300: cachemgr.cgi assertion (#1478)

22 months agoImproved 'stateless' helper-related classes (#1480)
Eduard Bagdasaryan [Wed, 20 Sep 2023 19:03:21 +0000 (19:03 +0000)] 
Improved 'stateless' helper-related classes (#1480)

No Squid functionality changes are expected beyond minor debugging
message changes.

22 months agoBug 5301: cachemgr.cgi not showing new manager interface URLs (#1479)
Amos Jeffries [Tue, 19 Sep 2023 08:45:27 +0000 (08:45 +0000)] 
Bug 5301: cachemgr.cgi not showing new manager interface URLs (#1479)

Also fix several related UI issues uncovered during testing:

* Prune the list of servers accessible via the CGI tool login.
 Their responses would be badly mangled if accessed via
 the old tools parse logic.
Also, hide the old login form if all servers use the new
manager interface.

* Ensure the 'menu' report is always used by default after
the CGI tool login. This prevents errors about MGR_INDEX
not being available on recent Squid releases. Restoring the
expected CGI tool behavior.

22 months agoExtend cache_log_message to problematic from-helper annotations (#1481)
Francesco Chemolli [Mon, 18 Sep 2023 15:00:23 +0000 (15:00 +0000)] 
Extend cache_log_message to problematic from-helper annotations (#1481)

    WARNING: Unsupported or unexpected from-helper annotation
        with a name reserved for Squid use

The above message is emitted for every helper response containing
problematic annotations. Let admins control this reporting using
cache_log_message directive and message id 69.

22 months agoImprove handling of empty lines received prior to request-line (#1470)
Egor Ignatov [Fri, 15 Sep 2023 09:50:16 +0000 (09:50 +0000)] 
Improve handling of empty lines received prior to request-line (#1470)

22 months agoSource Format Enforcement (#1476)
Alex Rousskov [Thu, 14 Sep 2023 14:52:04 +0000 (14:52 +0000)] 
Source Format Enforcement (#1476)

This change is a reference point for automated CONTRIBUTORS updates.

22 months agoBug 4156: comm.cc "!commHasHalfClosedMonitor(fd)" assertion (#1443)
Alex Rousskov [Mon, 11 Sep 2023 07:49:36 +0000 (07:49 +0000)] 
Bug 4156: comm.cc "!commHasHalfClosedMonitor(fd)" assertion (#1443)

This bug is specific to "half_closed_clients on" configurations.

    assertion failed: ... "isOpen(fd) && !commHasHalfClosedMonitor(fd)"
    location: comm.cc:1583 in commStartHalfClosedMonitor()

Squid asserts because Server schedules comm_read() after receiving EOF:
That extra read results in another EOF notification, and an attempt to
start monitoring an already monitored half-closed connection.

Upon detecting a potentially half-closed connection,
Server::doClientRead() should clear flags.readMore to prevent Server
from scheduling another comm_read(), but it does not and cannot do that
(without significant refactoring) because

* Server does not have access to flags.readMore
* flags.readMore hack is used for more than just "read more"

We worked around the above limitation by re-detecting half-closed
conditions and clearing flags.readMore after clientParseRequests(). That
fixed the bug but further increased poor code duplication across
ConnStateData::afterClientRead() and ConnStateData::kick() methods. We
then refactored by merging and moving that duplicated code into
clientParseRequests() and renamed that method to make backports safer.

22 months agoLog %err_code for ERR_RELAY_REMOTE transactions (#1472)
Alex Rousskov [Sat, 9 Sep 2023 03:01:52 +0000 (03:01 +0000)] 
Log %err_code for ERR_RELAY_REMOTE transactions (#1472)

For ERR_RELAY_REMOTE transactions, Squid was logging %err_code as "-"
because BuildHttpReply() was not updating HttpRequest::error or ALE.
That update was missing because the pre-computed response in those
transactions triggered a premature exit from BuildHttpReply().

BuildHttpReply() should not be updating errors at all, but significant
code refactoring required to fix that problem needs a dedicated change.

Also enabled regression testing for the fixed bug and the bug fixed in
recent commit ea3f56e.

22 months agoRestore errno in %err_detail for ERR_CONNECT_FAIL (#1368)
Alex Rousskov [Fri, 8 Sep 2023 06:05:36 +0000 (06:05 +0000)] 
Restore errno in %err_detail for ERR_CONNECT_FAIL (#1368)

Squid was sometimes logging %err_code/%err_detail as
ERR_CONNECT_FAIL/WITH_SERVER. It now logs
ERR_CONNECT_FAIL/WITH_SERVER+errno=111 (or similar).

When dealing with two error details, Squid was ignoring the latter one.
The new ErrorDetails code combines multiple details, reusing the
existing Security::ErrorDetail::brief() "a+b+c" syntax.

The new detail accumulation functionality may help detail other errors.

At least some of the logged errno details were lost in commit ba3fe8d.

22 months agoReport all AsyncJob objects (mgr:jobs) (#1468)
Eduard Bagdasaryan [Wed, 6 Sep 2023 02:32:22 +0000 (02:32 +0000)] 
Report all AsyncJob objects (mgr:jobs) (#1468)

This new cache manager report is useful in triage and test automation.
It complements mgr:objects, mgr:events, and mgr:filedescriptors reports.

22 months agoDo not use invasive lists to store CachePeers (#1424)
Eduard Bagdasaryan [Thu, 31 Aug 2023 23:00:01 +0000 (23:00 +0000)] 
Do not use invasive lists to store CachePeers (#1424)

Using invasive lists for CachePeer objects gives no advantages, but
requires maintaining non-standard error-prone code that leads to
excessive locking and associated memory overheads.

Also fixed a neighbors_init() bug that resulted in accessing an already
deleted "looks like this host" CachePeer object.

23 months agoAllow creation of RefCountable objects via Make() (#1458)
Amos Jeffries [Thu, 31 Aug 2023 14:09:50 +0000 (14:09 +0000)] 
Allow creation of RefCountable objects via Make() (#1458)

Compared to calling new() directly, using a Pointer-returning Make()
reduces memory leaks related to freshly allocated heap objects. Perfect
forwarding of constructor parameters through Make() minimizes overhead.

    const auto foo1 = new Foo(...); // XXX: leak-prone
    const auto foo2 = Foo::Pointer::Make(...); // OK

Future changes will prohibit RefCountable object creation via direct
new() calls and require using Make() or an equivalent safety API.

23 months agoPrep for 6.3 (#1466)
Amos Jeffries [Wed, 30 Aug 2023 16:41:54 +0000 (16:41 +0000)] 
Prep for 6.3 (#1466)

23 months agoEnable GitHub CodeQL static analysis in CI (#693)
Amos Jeffries [Tue, 29 Aug 2023 20:25:38 +0000 (20:25 +0000)] 
Enable GitHub CodeQL static analysis in CI (#693)

23 months agobasic_smb_lm_auth: fix 'no previous declaration' warnings (#1462)
Egor Ignatov [Thu, 24 Aug 2023 14:20:21 +0000 (14:20 +0000)] 
basic_smb_lm_auth: fix 'no previous declaration' warnings (#1462)

... that breaks build with --enable-strict-error-checking

23 months agoUpgrade Security::PeerOptions::dumpCfg() to std::ostream (#1460)
Eduard Bagdasaryan [Sat, 19 Aug 2023 16:30:29 +0000 (16:30 +0000)] 
Upgrade Security::PeerOptions::dumpCfg() to std::ostream (#1460)

This code improvement also allows future TLS options dumping code to use
Configuration::Component printing API.

No mgr:config output changes detected in basic tests.
No significant mgr:config output changes anticipated.

23 months agoDefine RefCount nullptr assignment operator (#1459)
Amos Jeffries [Fri, 18 Aug 2023 00:39:36 +0000 (00:39 +0000)] 
Define RefCount nullptr assignment operator (#1459)

If RefCount(C*) constructor becomes private, this change
will be needed to use 'foo=nullptr' syntax to clear a Pointer.

23 months agoCover OnTerminate() calls unrelated to exception handling (#1430)
Alex Rousskov [Wed, 16 Aug 2023 17:53:41 +0000 (17:53 +0000)] 
Cover OnTerminate() calls unrelated to exception handling (#1430)

The C++ standard lists many reasons[^1] for calling std::terminate().
All of them deal with an "exception handling failure". However, when
Squid bugs lead to an undefined behavior (e.g., by calling a pure
virtual function), some compilers also call std::terminate(). In those
cases, there may be no active exception, and our std::terminate()
handler's report about an "exception handling failure" (with "no active
exception") was confusing and misleading.

Also do not describe an exception when there is none. Callers that know
that the exception exists may continue to use CurrentException(),
especially if they do not need to report that exception on a dedicated
debugs() line. Other callers, including OnTerminate(), should use the
new CurrentExceptionExtra() manipulator.

[^1]: https://en.cppreference.com/w/cpp/error/terminate

23 months agoKeep ::helper objects alive while in use by helper_servers (#1389)
Eduard Bagdasaryan [Mon, 14 Aug 2023 01:39:29 +0000 (01:39 +0000)] 
Keep ::helper objects alive while in use by helper_servers (#1389)

Squid creates ::helper objects to manage a given configured helper. For
each ::helper object, Squid may create one or more helper_server objects
to manage communication with individual helper processes. A
helper_server object uses its so called "parent" ::helper object to
access configuration and for helper process death notification purposes.
There are no checks that the "parent" object is still alive when used.

The same problem applies to statefulhelper and helper_stateful_server.

helper_server code evidently attempted to extend their "parent" lifetime
using cbdata, but that does not work, especially in C++ world where the
object is destructed (and, hence, enters an undefined state) even though
its top-level memory is preserved by cbdata. Non-trivial members like
helper::queue (std::queue) and statefulhelper::reservations
(std::unordered_map) release their internal memory when destructed.

We now refcount ::helper objects to keep them alive until the last
object using them is gone. This does not result in reference loops
because the ::helper object uses raw dlink_node pointers to store its
helper_servers.

The following helpers (listed here by their container names) were
destructed while possibly still in use by their helper_server objects:
external_acl::theHelper, Ssl::CertValidationHelper::ssl_crt_validator,
Ssl::Helper::ssl_crtd. The following helpers are not destructed during
reconfiguration: redirectors, storeIds, basicauthenticators,
ntlmauthenticators, negotiateauthenticators, and digestauthenticators
(even though casual reading of relevant code may suggest otherwise).

This bug fix does not address or mark many remaining helper bugs.

23 months agoFix cbdata assertion in carpInit() (#1454)
Alex Rousskov [Sat, 12 Aug 2023 18:28:37 +0000 (18:28 +0000)] 
Fix cbdata assertion in carpInit() (#1454)

... after commit e7959b5

    FATAL: assertion failed: cbdata.cc:276: "c->locks > 0"

We cannot test cbdata validity of CachePeer pointers stored in
Config.peers because Config.peers own CachePeer objects. By definition,
owners should not lock their objects and do not need to test object
validity: Owners determine the lifetime of those objects! Naturally,
unlocked objects must not be tested for validity by others because to
test an object validity one has to have a lock that preserves object
metadata even after the object is invalidated (by its owner).

23 months agoBug 5294: ERR_CANNOT_FORWARD returned instead of ERR_DNS_FAIL (#1453)
Alex Rousskov [Sat, 12 Aug 2023 15:40:12 +0000 (15:40 +0000)] 
Bug 5294: ERR_CANNOT_FORWARD returned instead of ERR_DNS_FAIL (#1453)

Since 2017 commit fd9c47d, peer selection code stopped reporting
ERR_DNS_FAIL cases because PeerSelector::noteIps() treated DNS answers
without IP addresses as if at least one IP address was received. Without
seeing a DNS resolution error, the ultimate recipient of the DNS
resolution results (e.g., CONNECT tunneling or regular forwarding code)
used ERR_CANNOT_FORWARD to indicate a failure to find a forwarding path.

PeerSelector::noteIps() code mimicked legacy IPH code with regard to
handling of the addresses parameter. However, IPH caller had a special
emptyIsNil adjustment that was missing from the noteIps() call! We now
apply that adjustment to both noteIps() and IPH code paths.

Long-term, we should probably remove nil address container pointers.
Having two different ways to signal lack of IPs is dangerous. Currently,
there is only one known supplier of nil address container:
IpcacheStats.invalid code that validates ipcache_nbgethostbyname() name
parameter. Either the corresponding nil/empty name check should be
converted into an assertion (blaming the ipcache_nbgethostbyname()
caller for not validating the name) OR that checking code should supply
an empty address container to finalCallback().

23 months agoBug 4981: Work around in-call job invalidation bugs (#1428)
Shmaya [Fri, 11 Aug 2023 17:41:30 +0000 (17:41 +0000)] 
Bug 4981: Work around in-call job invalidation bugs (#1428)

Bug 4981 is one known case of such invalidation, but this workaround is
much broader than that bug context. We can speculate that architectural
problems described in commit e3b6f15 are behind (some of) these bugs.

23 months agoUse SBuf in CompositeSelectionDetails and DelayTaggedBucket (#1450)
Francesco Chemolli [Fri, 11 Aug 2023 11:21:16 +0000 (11:21 +0000)] 
Use SBuf in CompositeSelectionDetails and DelayTaggedBucket (#1450)

23 months agoMaintenance: use SBuf instead of SquidString in CommonPool (#1449)
Francesco Chemolli [Thu, 10 Aug 2023 05:51:42 +0000 (05:51 +0000)] 
Maintenance: use SBuf instead of SquidString in CommonPool (#1449)

23 months agoDocs: Update all Squid wiki URLs (#1448)
Amos Jeffries [Thu, 10 Aug 2023 00:34:01 +0000 (00:34 +0000)] 
Docs: Update all Squid wiki URLs (#1448)

The Squid Wiki now uses https:// instead of http://

Also, conversion to github altered the URL fragment
label syntax to all lowercase with hyphen instead of
underscore.

23 months agoDocs: Update all Squid Bugzilla URLs (#1447)
Amos Jeffries [Wed, 9 Aug 2023 19:52:33 +0000 (19:52 +0000)] 
Docs: Update all Squid Bugzilla URLs (#1447)

The Squid Bugzilla now uses https:// instead of http://

23 months agoMaintenance: stop using doxygen bug markers (#1445)
Amos Jeffries [Tue, 8 Aug 2023 19:16:24 +0000 (19:16 +0000)] 
Maintenance: stop using doxygen bug markers (#1445)

23 months agoReplaced ACLStrategised, enabling other ACL improvements (#1392)
Alex Rousskov [Tue, 8 Aug 2023 13:36:09 +0000 (13:36 +0000)] 
Replaced ACLStrategised, enabling other ACL improvements (#1392)

The ACLStrategised class stands in the way of several ACL bug fixes and
improvements because its design forces us to place ACL-like match()
methods inside non-ACL classes, creating two parallel matching
hierarchies: one rooted in the ACL class and one rooted in the Strategy
template. The two APIs have similar methods, but Strategy-based objects
lie outside the ACL hierarchy and cannot be treated as ACL objects.

ACLStrategised pairs an ACL-like matching algorithm (a Strategy-derived
class) with an ACLData-derived class. The need to combine the two is
genuine, but the same combination is best supported without creating a
parallel hierarchy of Strategy classes. The new ACL-derived
ParameterizedNode base class accomplishes that, addressing the old
ACLStrategised design XXX.

Strategy-derived classes were not pooled at all! With these changes, all
formerly ACLStrategised classes get individual memory pools, typically
one per acltype, with proper acltype-based naming in mgr:mem reports. No
other functionality changes intended.

23 months agoDo not use raw pointers to index CARP CachePeers (#1381)
Eduard Bagdasaryan [Tue, 8 Aug 2023 01:59:50 +0000 (01:59 +0000)] 
Do not use raw pointers to index CARP CachePeers (#1381)

Simplified and improved code safety by using CbcPointers instead.

Also fixed mgr:carp Cache Manager reports to detail relevant
cache_peers instead of all cache_peers. When mgr:carp report was added
in 2000 commit 8ee9b49, Squid did not index (or even distinguish!)
CARP cache_peers, and the reporting loop naturally iterated through all
cache_peers. 2002 commit b399543 added identification and indexing of
CARP peers but forgot to adjust the reporting loop.

Very similar changes will be applied to userhash and sourcehash
cache_peers. 2008 commit 63104e2 simply copied problematic CARP code to
add userhash and sourcehash cache_peer support. This change adds a few
reusable types with those upcoming improvements in mind.

23 months agoMaintenance: fix out of sync ChangeLog entry (#1446)
Amos Jeffries [Mon, 7 Aug 2023 13:04:08 +0000 (13:04 +0000)] 
Maintenance: fix out of sync ChangeLog entry (#1446)

23 months agoPrep for 6.2 (#1441)
Francesco Chemolli [Sat, 5 Aug 2023 23:48:22 +0000 (23:48 +0000)] 
Prep for 6.2 (#1441)

23 months agoSource Format Enforcement (#1439)
Alex Rousskov [Fri, 4 Aug 2023 00:55:41 +0000 (00:55 +0000)] 
Source Format Enforcement (#1439)

This change is a reference point for automated CONTRIBUTORS updates.

23 months agoCI: More HTTP caching and revalidation tests (#1440)
Alex Rousskov [Wed, 2 Aug 2023 05:00:49 +0000 (05:00 +0000)] 
CI: More HTTP caching and revalidation tests (#1440)

Use Daft cache-response test to monitor for bugs in basic caching code,
including bugs like the one fixed by commit c203754. Unlike the old
proxy-collapsed-forwarding test that uses concurrent requests, this test
varies basic response properties.

Use Daft accumulate-headers-after-304 test to monitor for bugs like the
one fixed by commit 55e1c6e. Unlike old proxy-update-headers-after-304,
this test focuses on certain _problematic_ HTTP 304 header updates.

2 years agoRemove Splay::walk() method (#1437)
Alex Rousskov [Mon, 31 Jul 2023 02:08:34 +0000 (02:08 +0000)] 
Remove Splay::walk() method (#1437)

Splay template class provided two traversal APIs: walk() and visit().
Primary code is only using visit(). Our tests were only testing walk().

2 years agoCacheManager: require /squid-internal-mgr/ URL path prefix (#1426)
Alex Rousskov [Sun, 30 Jul 2023 13:36:41 +0000 (13:36 +0000)] 
CacheManager: require /squid-internal-mgr/ URL path prefix (#1426)

    ERROR: Squid BUG: assurance failed: tok.skip(internalMagicPrefix)
    exception location: cache_manager.cc(173) ParseUrl

Due to poor code duplication, commit 92a5adb accidentally classified
URLs without a trailing slash in the magical prefix as valid cache
manager URLs, triggering the above ERRORs. We were denying such
"slashless" cache manager URLs (as invalid internal URLs) prior to that
commit. Since that commit, the ERRORs triggered by that commit
effectively denied them as well. Denying them properly results in
simpler/smaller code (than allowing them would), so we should avoid a UI
change and continue to deny them, at least for now.

This change also reduces duplication of magic prefix definitions. Other
pending work will completely eliminate that duplication in src/ code.

2 years agoRemove dead "String debugging" code (#1436)
Alex Rousskov [Sun, 30 Jul 2023 02:44:04 +0000 (02:44 +0000)] 
Remove dead "String debugging" code (#1436)

The corresponding src/String.cc code does not build since 2013 commit
5082718 (at least): That commit removed StringRegistry class declaration
the debugging code relied on. Since inception, the code could not be
enabled using ./configure options or make flags -- one had to modify
Squid sources to alter hard-coded `#define DEBUGSTRINGS 0` setting.

2 years agoBug 5290: pure virtual call in Ftp::Client constructor (#1429)
Alex Rousskov [Sat, 29 Jul 2023 17:44:59 +0000 (17:44 +0000)] 
Bug 5290: pure virtual call in Ftp::Client constructor (#1429)

    FATAL: Dying from an exception handling failure;
    exception: [no active exception]

Converting `this` to CbcPointer in a constructor of an abstract class
like Ftp::Client does not work because our virtual toCbdata() method
remains pure until the final/child class constructor runs.

Conceptually, the bug was probably introduced in 2013 commit 434a79b,
when FTP class hierarchy grew, making Ftp::Client an abstract class, but
the trigger was recent commit 337b9aa that removed CBDATA_CLASS() from
Ftp::Client class declaration. We discovered, described, and addressed
several such bugs in that commit, but we missed this case.

2 years agoESI: Fix build [-Wsingle-bit-bitfield-constant-conversion] (#1432)
Francesco Chemolli [Sat, 29 Jul 2023 08:41:53 +0000 (08:41 +0000)] 
ESI: Fix build [-Wsingle-bit-bitfield-constant-conversion] (#1432)

clang 16, the default on current fedora rawhide and centos stream 9,
complains about several ESI places:

    error: implicit truncation from 'int' to a one-bit wide bit-field
    changes value from 1 to -1
    [-Werror,-Wsingle-bit-bitfield-constant-conversion]

Turn 1-bit flags in ESI data structures from ints to unsigned ints to
avoid the problem.

2 years agoFix memory leak when reconfiguring multiline all-of ACLs (#1425)
Alex Rousskov [Sun, 23 Jul 2023 01:38:19 +0000 (01:38 +0000)] 
Fix memory leak when reconfiguring multiline all-of ACLs (#1425)

Normally, Acl::InnerNode::add() automatically registers stored ACL nodes
for future cleanup, but when we find the second all-of rule/line (with
the same ACL name), we do not add() the newly created OrNode and have to
explicitly register it to avoid memory leaks on reconfiguration.

Leaking since all-of ACL support was added in 2013 commit 6f58d7d.

2 years agoAllow unit tests to customize their initialization code (#1423)
Alex Rousskov [Sat, 22 Jul 2023 22:30:39 +0000 (22:30 +0000)] 
Allow unit tests to customize their initialization code (#1423)

CppUnit provides TestFixture::setUp() and tearDown() methods, but those
methods are executed before and after _each_ test case. Many single
TestFixture-derived classes register many test cases that need to run
some test program setup/initialization code just once. Counting past
setUp() calls would increase noise and likely introduce bugs.

Some of our test cases may actually need before/after cleanup -- the
functionality already provided by TestFixture::setUp()/tearDown()
methods.  Moreover, when multiple TestFixture-derived classes share the
same test executable, their collections of test cases are executed in
essentially random order (see commit 27685ef). In those use cases,
insuring one-time initialization via setUp() hacks would be especially
awkward and error-prone.

With this solution, a test program with custom needs just needs to
define a TestProgram-derived class that implements its one-time startup
logic. The same TestProgram class hierarchy might also prove useful in
future custom test execution adjustments.

Also migrated away from the "include main()" unit test design to avoid
adding risky hacks that register custom TestProgram-derived classes and
to reduce "magic" in test code (while following our style guidelines).
Every test programs now declares its own (trivial) main() rather than
getting it from include/unitTestMain.h.

2 years agoEncapsulate HttpHeaderEntry length calculation (#1416)
Eduard Bagdasaryan [Sat, 22 Jul 2023 18:58:31 +0000 (18:58 +0000)] 
Encapsulate HttpHeaderEntry length calculation (#1416)

2 years agoMinGW: PRINTF_FORMAT_ARG workaround (#1390)
Amos Jeffries [Sat, 22 Jul 2023 17:30:22 +0000 (17:30 +0000)] 
MinGW: PRINTF_FORMAT_ARG workaround (#1390)

MinGW produces warnings about not supporting the printf '%zu' format
code when the 'printf' format archetype is used to validate code.

Checking against the 'gnu_printf' format archetype avoids this bad
warning. We accept the lower rate of error detection since other OS
builds verify against the 'printf' format archetype.

We also removed undocumented, inconsistent, and presumably unused
support for providing custom PRINTF_FORMAT_ARG macros during Squid
build. This removal simplifies code.

2 years agoAdd SQUID_CHECK_LIB_WORKS macro (#1333)
Amos Jeffries [Sat, 22 Jul 2023 15:17:32 +0000 (15:17 +0000)] 
Add SQUID_CHECK_LIB_WORKS macro (#1333)

... to run validation for a library after SQUID_AUTO_LIB detection.

A typical use of this macro could be:
```
  SQUID_AUTO_LIB(foo,[Foo],[LIBFOO])
  SQUID_CHECK_LIB_WORKS(foo,[
    PKG_CHECK_MODULES([LIBFOO],[foo >= 1.0],[],[
      LIBFOO_LIBS=""
    ])
    AC_CHECK_HEADERS([foo.h],[],[LIBFOO_LIBS=""])
  ])
```

Update of configure.ac to use this macro uncovered and
fixed a bug which may have broken libnettle detection on
some systems.

2 years agoRemove outdated Win32 select() module (#1419)
Amos Jeffries [Tue, 18 Jul 2023 16:04:22 +0000 (16:04 +0000)] 
Remove outdated Win32 select() module (#1419)

This code has quite a lot of bitrot compared to
the POSIX select(2) code in ModSelect.cc.

Modern Windows and MinGW apparently support
the POSIX API. So we should be able to just
use the normal ModSelect now. Any adjustments
should be added to ModSelect.cc when later
testing proves a need.

2 years agoMiss if a 304 update would exceed reply_header_max_size (#1420)
Eduard Bagdasaryan [Mon, 17 Jul 2023 09:56:11 +0000 (09:56 +0000)] 
Miss if a 304 update would exceed reply_header_max_size (#1420)

Fetch the resource unconditionally when a 304 (Not Modified) response to
an internal cache revalidation request grows cached HTTP response
headers beyond the reply_header_max_size limit.

2 years agoDo not use static initialization to register modules (#1422)
Alex Rousskov [Fri, 14 Jul 2023 17:46:30 +0000 (17:46 +0000)] 
Do not use static initialization to register modules (#1422)

    ERROR: ... Unknown authentication scheme 'ntlm'.

When a translation unit does not contain main() and its code is not used
by the rest of the executable, the linker may exclude that translation
unit from the executable. This exclusion by LTO may happen even if that
code _is_ used to initialize static variables in that translation unit:
"If no variable or function is odr-used from a given translation unit,
the non-local variables defined in that translation unit may never be
initialized"[^1].

[^1]: https://en.cppreference.com/w/cpp/language/initialization

For example, src/auth/ntlm/Scheme.o translation unit contains nothing
but NtlmAuthRr class definition and static initialization code. The
linker knows that the rest of Squid does not use NtlmAuthRr and excludes
that translation unit from the squid executable, effectively disabling
NTLM module registration required to parse "auth_param ntlm" directives.

The problem does affect existing NTLM module, and may affect any future
module code as we reduce module's external footprint. This change
converts all RegisteredRunner registrations from using side effects of
static initialization to explicit registration calls from SquidMain().
Relying on "life before main()" is a design bug. This PR fixes that bug
with respect to RegisteredRunner registrations.

Due to indeterminate C++ static initialization order, no module can
require registration before main() starts. Thus, moving registration
timing to the beginning of SquidMain() should have no negative effects.

The new registration API still does not expose main.cc to any module
details (other than the name of the registration function itself). We
still do not need to #include any module headers into main.cc. Compiler
or linker does catch most typos in RegisteredRunner names.

Unfortunately, explicit registration still cannot prevent bugs where we
forget to register a module or fail to register a module due to wrong
registration code guards. Eventually, CI will expose such bugs.

2 years agoRemoved unused HttpHeader member functions (#1415)
Eduard Bagdasaryan [Thu, 13 Jul 2023 15:13:38 +0000 (15:13 +0000)] 
Removed unused HttpHeader member functions (#1415)

HttpHeader::insertEntry() is unused since 2015 commit 81ab22b.

2 years agoDrop ClientHttpRequest::flags::internal (#1414)
Amos Jeffries [Wed, 12 Jul 2023 23:03:32 +0000 (23:03 +0000)] 
Drop ClientHttpRequest::flags::internal (#1414)

This flag is unnecessary when `HttpRequest::flags::internal`
is available, which is almost all code needing to detect
internal traffic.

The exception to this is parsing prior to HttpRequest
creation, which already uses internalCheck() API instead.

2 years agoFix build on GNU/Hurd (#1417)
Amos Jeffries [Wed, 12 Jul 2023 11:55:15 +0000 (11:55 +0000)] 
Fix build on GNU/Hurd (#1417)

Definitions of htonl() and htons() require these headers, in this order.

2 years agoHandle helper program startup failure as its death (#1395)
Eduard Bagdasaryan [Mon, 10 Jul 2023 12:07:53 +0000 (12:07 +0000)] 
Handle helper program startup failure as its death (#1395)

Squid quits when started helper programs die too fast without responding
to requests[^1] because such a Squid instance is unlikely to provide
acceptable service (and a full restart may actually fix the problem or,
at the very least, is more likely to bring the needed admin attention).

The same logic now applies when Squid fails to start a helper (i.e. when
ipcCreate() fails). There is no conceptual difference between those two
kinds of failures as far as helper handling code is concerned, so we now
treat them the same way.

Without these changes, helper start failures may result in an unusable
(but running) Squid instance, especially if no helpers can be started at
all, because new transactions get stuck waiting in the queue until
clients timeout. Such persistent ipcCreate() failures may be caused, for
example, by its fork() hitting an overcommit memory limits.

[^1]: The actual condition excludes cases where at least startup=N
helpers are still running. That exclusion and other helper failure
handling details are problematic, but adjusting that code is outside
_this_ fix scope: Here, we only apply _existing_ handling logic to a
missed case.

2 years agoMaintenance: replace most NULL with nullptr (#1402)
Amos Jeffries [Sun, 9 Jul 2023 17:15:28 +0000 (17:15 +0000)] 
Maintenance: replace most NULL with nullptr (#1402)

2 years agoBug 5187: Work around REQMOD satisfaction regression (#1400)
Andrew Novikov [Sun, 9 Jul 2023 02:05:56 +0000 (02:05 +0000)] 
Bug 5187: Work around REQMOD satisfaction regression (#1400)

Commit ba3fe8d broke ICAP REQMOD satisfaction transactions. In some
cases, this workaround may resurrect Squid Bug 5187. Triage available at
https://bugs.squid-cache.org/show_bug.cgi?id=5187#c6

2 years agoCI: Test %err_code logging for "early" request handling errors (#1396)
Alex Rousskov [Fri, 7 Jul 2023 10:00:18 +0000 (10:00 +0000)] 
CI: Test %err_code logging for "early" request handling errors (#1396)

Use Daft malformed-request test to monitor for bugs like those fixed
by master/v7 commit 8a628a1.

2 years agoSupport read-only ClpMap iteration by ClpMap users (#1409)
Francesco Chemolli [Thu, 6 Jul 2023 14:55:30 +0000 (14:55 +0000)] 
Support read-only ClpMap iteration by ClpMap users (#1409)

This change makes it possible for anticipated future ClpMap users (e.g.,
stat_ipcache_get()) to report their cache contents. No changes to
ClpMap::Entry and related old types except making them public.

The alternative solution -- a visitor design pattern -- was rejected
because `for` loops are a bit easier to read than for_each() loops.

No Squid functionality changes expected.

2 years agoMaintenance: Remove unused xstrtoul() from the global scope (#1407)
Francesco Chemolli [Wed, 5 Jul 2023 21:30:14 +0000 (21:30 +0000)] 
Maintenance: Remove unused xstrtoul() from the global scope (#1407)

xstrtoul() is only used by xstrtoui() in the same module, no need to
export it to the global namespace