]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
7 years ago4.0.14 SQUID_4_0_14
Amos Jeffries [Thu, 8 Sep 2016 14:10:21 +0000 (02:10 +1200)] 
4.0.14

7 years agoPrep for 4.0.14 and 3.5.21
Amos Jeffries [Thu, 8 Sep 2016 14:02:19 +0000 (02:02 +1200)] 
Prep for 4.0.14 and 3.5.21

7 years agoSourceFormat Enforcement
Source Maintenance [Thu, 8 Sep 2016 12:12:09 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoSquid crashes on shutdown while cleaning up idle ICAP connections, part2
Christos Tsantilas [Thu, 8 Sep 2016 10:25:37 +0000 (13:25 +0300)] 
Squid crashes on shutdown while cleaning up idle ICAP connections, part2

Fixes to allow make check work:
 - Fix tests/stub_pconn.cc to correctly implement a stub IdleConnList
 - Replace reinterpret_cast with static_cast to avoid errors when clang is used.
   The IdleConnList is now a hash_link kid and static_cast is the correct one.

7 years agoSquid crashes on shutdown while cleaning up idle ICAP connections.
Christos Tsantilas [Thu, 8 Sep 2016 09:08:02 +0000 (12:08 +0300)] 
Squid crashes on shutdown while cleaning up idle ICAP connections.

The global Adaptation::Icap::TheConfig object is automatically destroyed
when Squid exits. Its destructor destroys Icap::ServiceRep objects that,
in turn, close all open connections in the idle connections pool. Since
this happens after comm_exit has destroyed all Comm structures
associated with those connections, Squid crashes.

This patch uses updated RegisteredRunners API to close all connections
in existing connections pools before Squid cleans up the Comm subsystem.

Also added a new IndependentRunner class to the RegistersRunner API,
which must be used for runners that are destroyed by external forces,
possibly while still being registered. IndependentRunner objects
unregister themselves from Runners registry when they are destroyed.

The finishShutdown() method is now virtual and may be overloaded to
implement independent runner cleanup during main loop (and/or to support
complex cleanup actions that require calling other virtual methods). The
method is still called for all registered runners but it no longer
destroys the runner. For dependent runners, the destruction happens soon
after the finishShutdown event ends but also during the main loop
(unless the runner has managed to register after the main loop ended).

This patch replaces the r14575 temporary fix.

This is a Measurement Factory project.

7 years agoHTTP: do not allow Proxy-Connection to override Connection header
Amos Jeffries [Thu, 8 Sep 2016 08:06:43 +0000 (20:06 +1200)] 
HTTP: do not allow Proxy-Connection to override Connection header

Proxy-Connection header is never actually valid, it is relevant in
HTTP/1.0 messages only when Connection header is missing and not
relevant at all in HTTP/1.1 messages.

This fixes part of the behaviour, making Squid use Connection header
for persistence (keep-alive vs close) checking if one is present
instead of letting Proxy-Connection override it.

TODO: Proxy-Connection still needs to be ignored completely when
      the message version is HTTP/1.1.

7 years agoSourceFormat Enforcement
Source Maintenance [Tue, 6 Sep 2016 12:12:18 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoWrong error_depth value printed with %ssl::<cert_errors
Christos Tsantilas [Tue, 6 Sep 2016 11:00:51 +0000 (14:00 +0300)] 
Wrong error_depth value printed with %ssl::<cert_errors

This patch fixes the following problems:
- Squid stores the depth information only for the first certificate error
- The Ssl::CertError assignment operations does not update depth member
- The Ssl::CertError equal/not equal operators does not check depth information

This is a Measurement Factory project

7 years agoSSL CN wildcard must only match a single domain component [fragment].
Christos Tsantilas [Tue, 6 Sep 2016 08:12:10 +0000 (11:12 +0300)] 
SSL CN wildcard must only match a single domain component [fragment].

When comparing the requested domain name with a certificate Common Name,
Squid expanded wildcard to cover more than one domain name label (a.k.a
component), violating RFC 2818 requirement[1]. For example, Squid
thought that wrong.host.example.com matched a *.example.com CN.

    [1] "the wildcard character * ... is considered to match any single
    domain name component or component fragment. E.g., *.a.com matches
    foo.a.com but not bar.foo.a.com".

In other contexts (e.g., ACLs), wildcards expand to all components.
matchDomainName() now accepts a mdnRejectSubsubDomains flag that selects
the right behavior for CN match validation.

The old boolean honorWildcards parameter replaced with a flag, for clarity
and consistency sake.

This patch also handles the cases where the host name consists only from dots
(eg malformed Host header or SNI info). The old code has undefined behaniour
in these cases. Moreover it handles the cases a certificate contain zero length
string as CN or alternate name.

This is a Measurement Factory project.

7 years agoHTTP: MUST always revalidate Cache-Control:no-cache responses.
Eduard Bagdasaryan [Tue, 6 Sep 2016 07:41:16 +0000 (19:41 +1200)] 
HTTP: MUST always revalidate Cache-Control:no-cache responses.

Squid MUST NOT use a CC:no-cache response for satisfying subsequent
requests without successful validation with the origin server. Squid
violated this MUST because Squid mapped both "no-cache" and
"must-revalidate"/etc. directives to the same ENTRY_REVALIDATE flag
which was interpreted as "revalidate when the cached response becomes
stale" rather than "revalidate on every request".

This patch splits ENTRY_REVALIDATE into:
- ENTRY_REVALIDATE_ALWAYS, for entries with CC:no-cache and
- ENTRY_REVALIDATE_STALE, for entries with other related CC directives
  like CC:must-revalidate and CC:proxy-revalidate.

Reusing ENTRY_CACHABLE_RESERVED_FOR_FUTURE_USE value for the more
forgiving ENTRY_REVALIDATE_STALE (instead of the more aggressive
ENTRY_REVALIDATE_ALWAYS) fixes the bug for the already cached entries -
they will be revalidated and stored with the correct flag on the next
request.

7 years agoHTTP: validate Content-Length header values
Alex Rousskov [Tue, 6 Sep 2016 02:45:20 +0000 (14:45 +1200)] 
HTTP: validate Content-Length header values

Squid is violating HTTP MUSTs by forwarding messages with
problematic Content-Length values. Some of those bugs were fixed in
trunk r14215. This change handles multiple Content-Length values inside
one header field, negative values, and trailing garbage. Handling the
former required a change in the overall Content-Length interpretation
approach (which is why it was previously left as a TODO).

Squid now passes almost all Co-Advisor tests devoted to this area. We
are not 100% done though: We still need to handle malformed values with
leading signs (e.g., "-0" or "+1"). However, I hope that the remaining
problems are relatively minor. I do not plan on addressing them in the
foreseeable future.

Also improved httpHeaderParseOffset(): Added detection of overflowing
and underflowing integer values; polished malformed value detection code
(Linux strtoll(3) manual page has a good example). The function no
longer considers empty strings valid and reports trailing characters.
The function still accepts leading whitespace and signs. It is still the
wrong approach to HTTP numbers parsing, but further improvements are out
of scope because they are complicated and would require significant
caller rewrites.

7 years agoSourceFormat Enforcement
Source Maintenance [Mon, 5 Sep 2016 00:12:08 +0000 (00:12 +0000)] 
SourceFormat Enforcement

7 years agoGnuTLS: support for TLS session resume (part 2)
Amos Jeffries [Sun, 4 Sep 2016 21:29:19 +0000 (09:29 +1200)] 
GnuTLS: support for TLS session resume (part 2)

7 years agoSourceFormat Enforcement
Source Maintenance [Thu, 25 Aug 2016 18:12:21 +0000 (18:12 +0000)] 
SourceFormat Enforcement

7 years agoMUST respond with 414 (URI Too Long) when request target exceeds limits.
Eduard Bagdasaryan [Thu, 25 Aug 2016 17:26:02 +0000 (11:26 -0600)] 
MUST respond with 414 (URI Too Long) when request target exceeds limits.

Before the fix, Squid simply closed client connection after receiving a
huge URI (or a huge request-line), violating the RFC 7230 MUST. This
happened because a high-level Must(have buffer space) check in
ConnStateData::clientParseRequests() would throw an exception. Now these
problems are detected inside the low-level RequestParser code, where we
can distinguish huge URIs from huge methods.

7 years agoFix logformat unable to configure codes with /-escape
Diogenes S. Jesus [Wed, 24 Aug 2016 13:31:24 +0000 (01:31 +1200)] 
Fix logformat unable to configure codes with /-escape

7 years agoCleanup: remove needless LockingPointer::resetWithoutLocking(nullptr)
Amos Jeffries [Fri, 19 Aug 2016 06:55:38 +0000 (18:55 +1200)] 
Cleanup: remove needless LockingPointer::resetWithoutLocking(nullptr)

7 years agoAdd missing updateLimits() to stub_HelperChildConfig.cc
Amos Jeffries [Fri, 19 Aug 2016 05:05:46 +0000 (17:05 +1200)] 
Add missing updateLimits() to stub_HelperChildConfig.cc

7 years agoFixed onPersistentOverload initialization in stub Helper::ChildConfig.
Alex Rousskov [Fri, 19 Aug 2016 04:11:41 +0000 (22:11 -0600)] 
Fixed onPersistentOverload initialization in stub Helper::ChildConfig.

Detected by Coverity Scan:
* CID 1255045: Uninitialized members (UNINIT_CTOR)
* CID 1255046: Uninitialized members (UNINIT_CTOR)

7 years agoRelease notes update
Amos Jeffries [Fri, 19 Aug 2016 03:06:27 +0000 (15:06 +1200)] 
Release notes update

7 years agoDo not log error:transaction-end-before-headers after invalid requests.
Alex Rousskov [Fri, 19 Aug 2016 02:32:01 +0000 (20:32 -0600)] 
Do not log error:transaction-end-before-headers after invalid requests.

Squid was not consuming read leftovers after failing to parse a request.
Starting with r14752, those leftovers were misinterpreted as another
unparsed request, creating an extra error:transaction-end-before-headers
access.log line after every error:invalid-request line (and probably
after every error:request-too-large line).

To stop Squid from accidentally reading new bytes and misinterpreting
them as another request, I was tempted to also clear flags.readMore
after consuming unparsable leftovers. In my tests, the flag is cleared
in ConnStateData::quitAfterError() called from clientTunnelOnError(),
but that logic looks rather fragile. I resisted the temptation to
improve it because controlling reads is a complicated matter (especially
in on_unsupported_protocol context) outside this logging fix scope.

7 years agoBug 4570: crash after rev.14755
Amos Jeffries [Thu, 18 Aug 2016 12:43:27 +0000 (00:43 +1200)] 
Bug 4570: crash after rev.14755

7 years agoFixed TLS message type logging when SslBump parses TLS handshake.
Alex Rousskov [Wed, 17 Aug 2016 23:15:03 +0000 (17:15 -0600)] 
Fixed TLS message type logging when SslBump parses TLS handshake.

C++ streams write uint8_t as char.

7 years agoDo not access-log chunked non-persistent responses with _ABORTED suffix.
Alex Rousskov [Wed, 17 Aug 2016 23:11:56 +0000 (17:11 -0600)] 
Do not access-log chunked non-persistent responses with _ABORTED suffix.

The lack of Content-Length response header and STREAM_FAILED are not
closely related. ClientStreams should be capable of delivering complete
[chunked] responses without Content-Length header. If the peer response
was not chunked and lacked Content-Length, then we will return
STREAM_FAILED when false checkTransferDone() indicates that we did not
get everything yet but flags.complete forces us to stop sending.

7 years agoDo not access-log SslBump-faked CONNECTs with _ABORTED suffixes.
Alex Rousskov [Wed, 17 Aug 2016 22:46:38 +0000 (16:46 -0600)] 
Do not access-log SslBump-faked CONNECTs with _ABORTED suffixes.

All successful transactions, including fake CONNECTs, must be removed
from the pipeline (via a finished() call) to avoid _ABORTED suffix
added by Pipeline::terminateAll() which always calls noteIoError().

Also added a check that the remaining request in the pipeline is the
expected CONNECT. Old comments said as much but the code did not throw
if a different request was pipelined (and asserted if more than one
requests were). We now throw in all these problematic cases. I cannot
track all ConnStateData::getSslContextStart() callers deep enough to
be sure that only a single CONNECT can get through, but the change
reflects the expected behavior (and it may be useful to discover any
reality deviations from our expectations).

7 years agoCleanup: remove many needless references to SSL
Amos Jeffries [Wed, 17 Aug 2016 14:24:07 +0000 (02:24 +1200)] 
Cleanup: remove many needless references to SSL

7 years agoMaintenance: update translation .POT and .PO data
Amos Jeffries [Wed, 17 Aug 2016 06:22:38 +0000 (18:22 +1200)] 
Maintenance: update translation .POT and .PO data

7 years agoBetter support for unknown URL schemes
Amos Jeffries [Wed, 17 Aug 2016 00:38:25 +0000 (12:38 +1200)] 
Better support for unknown URL schemes

Squid already contains AnyP::PROTO_UNKNOWN support for unknown protocols
but currently does not preserve the actual string value received for them.

This adds a textual representation ('image') to the UriScheme object to
fill that gap and ensure that all URL representations (ie cache keys,
logs and outgoing messages) are generated with the scheme string as it
was received rather than implicitly via a registered protocol type.

Future work:
* add ACL support for arbitrary scheme names
* support for comparisons of unknown schemes

7 years agoDocs: release notes for connections_encrypted ACL
Amos Jeffries [Wed, 17 Aug 2016 00:26:45 +0000 (12:26 +1200)] 
Docs: release notes for connections_encrypted ACL

7 years agoBug 3025: Proxy-Authenticate problem using ICAP server
mkishi [Mon, 15 Aug 2016 14:44:43 +0000 (02:44 +1200)] 
Bug 3025: Proxy-Authenticate problem using ICAP server

7 years agoBug 4563: duplicate code in httpMakeVaryMark
Amos Jeffries [Mon, 15 Aug 2016 11:26:37 +0000 (23:26 +1200)] 
Bug 4563: duplicate code in httpMakeVaryMark

7 years agoFix SSL-Bump failure results in SEGFAULT
Amos Jeffries [Mon, 15 Aug 2016 11:14:29 +0000 (23:14 +1200)] 
Fix SSL-Bump failure results in SEGFAULT

7 years agoFixed build on systems needing explicit <utility> in RegexPattern.cc.
Alex Rousskov [Sun, 14 Aug 2016 01:17:57 +0000 (19:17 -0600)] 
Fixed build on systems needing explicit <utility> in RegexPattern.cc.

... after r14795.

Also removed bogus comments implying that std::move() does something to
its argument. That function is just a type cast; it does nothing else!
We use std::move() so that the compiler picks a move constructor or
assignment (where available). In case of RegexPattern::flags, using
std::move() has no effect because integers do not have those move
methods. However, it may be a good idea to use std::move() anyway
because the type of RegexPattern::flags might change in the future and
for consistency sake. Thus, I did not remove std::move(), only comments.

7 years agoSourceFormat Enforcement
Source Maintenance [Sat, 13 Aug 2016 12:12:14 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoBug 4561: Replace use of default move operators with explicit implementation
Amos Jeffries [Sat, 13 Aug 2016 10:12:06 +0000 (22:12 +1200)] 
Bug 4561: Replace use of default move operators with explicit implementation

The '= default' syntax for move assignment operator and constructor can
result in double-free crashes when the class type containspointer members
since the trivial move uses std::memmove() which does not perform the
required zeroing/nullptr of the temporary source object being moved.

7 years agoMake Squid death due to overloaded helpers optional.
Eduard Bagdasaryan [Sat, 13 Aug 2016 00:43:50 +0000 (12:43 +1200)] 
Make Squid death due to overloaded helpers optional.

Added on-persistent-overload=action option to helpers. Helper overload
is defined as running with an overflowing queue. Persistent helper
overload is [still] defined as being overloaded for more than 3 minutes.

The default behavior is unchanged(*) -- Squid worker dies with a fatal
error at the attempt to submit a new request to a persistenly overloaded
helper. This default behavior can also be configured explicitly using
on-persistent-overload=die.

With on-persistent-overload=ERR, when dealing with a persistently
overloaded helper, Squid immediately skips the helper request and sends
an ERR response to the caller. Squid informs the admin when it starts
and when it stops skipping helper requests due to persistent overload.

The code had conflicting notions of an "overloaded helper". The external
ACL helper, the URL rewriter, and the store ID code used queueFull() to
test whether the new request would overflow the queue (and, hence,
overload the helper), but queueFull() itself did not check whether the
queue was full! It checked whether the queue was already overflowing.
This confusion resulted in that code scheduling one extra helper request
before enabling bypass. The code and its documentation are now more
consistent (and better match the "overload" terminology used by the new
configuration option, which also feels better than calling the helper
"full").

(*) Resolving the above confusion resulted in minor (one request)
differences in the number of helper requests queued by Squid for
external ACL, URL rewriting, and store ID helpers, with the adjusted
behavior [better] matching the documentation.

7 years agoBug 4561: revert r14783
Amos Jeffries [Fri, 12 Aug 2016 17:16:38 +0000 (05:16 +1200)] 
Bug 4561: revert r14783

7 years agoCleanup cleanup: parseNamedIntList needs #if protections since r14789.
Alex Rousskov [Thu, 11 Aug 2016 20:49:22 +0000 (14:49 -0600)] 
Cleanup cleanup: parseNamedIntList needs #if protections since r14789.

There are design problems with r14789, but I am only addressing the
build failure.

7 years agoSourceFormat Enforcement
Source Maintenance [Wed, 10 Aug 2016 06:12:03 +0000 (06:12 +0000)] 
SourceFormat Enforcement

7 years agoCleanup: refactor FwdState pinned connection handling slightly
Amos Jeffries [Wed, 10 Aug 2016 00:56:30 +0000 (12:56 +1200)] 
Cleanup: refactor FwdState pinned connection handling slightly

Don't try to be too smart with indirect serverConn == NULL details. It
just confuses static analysis.

This code ordering should resolve the false positive Coverity Scan
issue 740373 and let any real problem show through.

7 years agoCleanup: make static analyzers happier with legacy config parsing
Amos Jeffries [Wed, 10 Aug 2016 00:45:22 +0000 (12:45 +1200)] 
Cleanup: make static analyzers happier with legacy config parsing

Use return statements after self_destruct() helps Coverity Scan see that
there is no NULL-dereference going on and lowers is false-positive rate.

7 years agoCleanup: remove some minor memory leaks in external ACL config parsing
Amos Jeffries [Wed, 10 Aug 2016 00:01:26 +0000 (12:01 +1200)] 
Cleanup: remove some minor memory leaks in external ACL config parsing

 Detected by Coveruty Scan. Issue 434089

7 years agoFix typo in rev.14786
Amos Jeffries [Tue, 9 Aug 2016 22:40:09 +0000 (10:40 +1200)] 
Fix typo in rev.14786

7 years agoBug 4428: mal-formed Cache-Control:stale-if-error header
Amos Jeffries [Tue, 9 Aug 2016 22:03:59 +0000 (10:03 +1200)] 
Bug 4428: mal-formed Cache-Control:stale-if-error header

7 years agoFix logic error in rev.14321
Amos Jeffries [Tue, 9 Aug 2016 14:08:25 +0000 (02:08 +1200)] 
Fix logic error in rev.14321

 Using !=0 on both string compares means any login= value will permit
 40x responses through. Only PASS and PASSTHRU should be doing that.

 Detected by Coverity Scan. Issue 1364711

7 years agoCleanup: fix several minor memory leaks in config parsing
Amos Jeffries [Tue, 9 Aug 2016 13:29:44 +0000 (01:29 +1200)] 
Cleanup: fix several minor memory leaks in config parsing

Most of these are only short-term leaks that occur when aborting due to
bad configuration. But getting rid of them will reduce noise in analysis.

 Detected by Coverity Scan. Issue 1364740136474113647431364745.

7 years agoCleanup: add move semantics to CbcPointer template
Amos Jeffries [Tue, 9 Aug 2016 13:27:06 +0000 (01:27 +1200)] 
Cleanup: add move semantics to CbcPointer template

 Detected by Coverity Scan. Issue 1364735

7 years agoCleanup: fix minor memory leak in squid.conf parsing
Amos Jeffries [Mon, 8 Aug 2016 23:34:31 +0000 (11:34 +1200)] 
Cleanup: fix minor memory leak in squid.conf parsing

 Detected by Coverity Scan. Issue 1154224

7 years agoCleanup: remove unused Ipc::MemMap::ttl
Amos Jeffries [Mon, 8 Aug 2016 23:20:36 +0000 (11:20 +1200)] 
Cleanup: remove unused Ipc::MemMap::ttl

 Detected by Coverity Scan. Issue 1364747

7 years agoCleanup: make static analysis a bit happier
Amos Jeffries [Mon, 8 Aug 2016 17:51:44 +0000 (05:51 +1200)] 
Cleanup: make static analysis a bit happier

Use return after self_destruct() to make code path analysis a bit better.

 Detected by Coverity Scan. Issue 1154203

7 years agoFix eCAP build error after rev.14778
Eduard Bagdasaryan [Mon, 8 Aug 2016 10:40:57 +0000 (22:40 +1200)] 
Fix eCAP build error after rev.14778

7 years agoCleanup: make static analyzers happier
Amos Jeffries [Sat, 6 Aug 2016 06:06:27 +0000 (18:06 +1200)] 
Cleanup: make static analyzers happier

Coverity and other static analyers are not smart enough to detect that
self_destruct() does not return.SO get confused about NULL derefernces.

 Coverity Scan. Issues 1364730136472713647241364729, 434088.

7 years agoCleanup: check URN list before using it
Amos Jeffries [Sat, 6 Aug 2016 05:55:37 +0000 (17:55 +1200)] 
Cleanup: check URN list before using it

The check should not be needed, the URN parse function always allocates.
But do it at the right time even so.

 Detected by Coverity Scan. Issue 434062

7 years agoFix clang errors with global InstanceId initialization
Amos Jeffries [Sat, 6 Aug 2016 04:49:55 +0000 (16:49 +1200)] 
Fix clang errors with global InstanceId initialization

Move static member Last into change() method to avoid initialization order
errors when a caller uses a global InstanceId object before the library
instantiating its template is initialized.

Also, convert the Prefix static member to a constant string in a prefix()
method to avoid the same issue there.

7 years agoCleanup: remove some minor memory leaks on config parser self_destruct
Amos Jeffries [Fri, 5 Aug 2016 22:00:51 +0000 (10:00 +1200)] 
Cleanup: remove some minor memory leaks on config parser self_destruct

 Identified by Coverity Scan. ID 13647421364744.

7 years ago4.0.13 SQUID_4_0_13
Amos Jeffries [Fri, 5 Aug 2016 12:51:46 +0000 (00:51 +1200)] 
4.0.13

7 years agoBug 4551: fix exceptions in new chunked decoder
Amos Jeffries [Tue, 2 Aug 2016 15:06:37 +0000 (03:06 +1200)] 
Bug 4551: fix exceptions in new chunked decoder

... fixing incremental CRLF parsing in both chunked encoding and
status-line parsing contexts.

7 years agoTry fix "'fatal' was not declared in this scope" compile error after r14769
Christos Tsantilas [Mon, 1 Aug 2016 13:57:14 +0000 (16:57 +0300)] 
Try fix "'fatal' was not declared in this scope" compile error after r14769

7 years agoSourceFormat Enforcement
Source Maintenance [Mon, 1 Aug 2016 12:12:15 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoBug 4555: Minor improvements to error pages CSS
Marcos Mello [Mon, 1 Aug 2016 11:40:09 +0000 (23:40 +1200)] 
Bug 4555: Minor improvements to error pages CSS

7 years agoFetch missing certificates
Christos Tsantilas [Mon, 1 Aug 2016 11:27:44 +0000 (14:27 +0300)] 
Fetch missing certificates

Many web servers do not have complete certificate chains. Many browsers use
certificate extensions of the server certificate and download the missing
intermediate certificates automatically from the Internet.
This patch add this feature to Squid.

The information for missing issuer certificates provided by the Authority
Information Access X509 extension. This describes the format and the location
of additional information provided by the issuer of the certificate.

This patch:
  - Implements a class Downloader as an independet AsyncJob class. This new
    class can be used by internal squid subsystems to download objects from
    the network.
  - Modify Ssl::PeerConnector class to use new Downloader class to
    retrieve missing certificates from the net. The URIs of missing
    certificates from the Authority Information Access X509 extension.
  - Implements a new basic certificates parser based on openSSL for the
    TLS handshake messages parser.
  - Modify the Ssl::ServerBio class to:
     * Buffer the Server Hello message and not pass it to the openSSL library
       until downloading missing certificates, if any, is finished.
     * Extract server certificates from server hello message.
       This is required to check if there are missing certificates, and if yes
       give the chance to squid to download missing certificates and complete
       certificate chains before pass them for processing to openSSL

TODO:
  - Add support for certs-only CMS message.
    From  RFC 4325:
    "Where the information is available via HTTP or FTP, accessLocation
    MUST be a uniformResourceIdentifier and the URI MUST point to either
    a single DER encoded certificate as specified in [RFC2585] or a
    collection of certificates in a BER or DER encoded "certs-only" CMS
    message as specified in [RFC2797]. "
    ...
    "Conforming applications that support HTTP or FTP for accessing
    certificates MUST be able to accept individual DER encoded
    certificates and SHOULD be able to accept "certs-only" CMS messages."

This is a Measurement Factory project

7 years agomerge from trunk-r14768
Christos Tsantilas [Mon, 1 Aug 2016 11:11:47 +0000 (14:11 +0300)] 
merge from trunk-r14768

7 years agoPolishing fixes from squid-dev review
Christos Tsantilas [Mon, 1 Aug 2016 09:42:45 +0000 (12:42 +0300)] 
Polishing fixes from squid-dev review

7 years agoFix crash after rev.14735
Alex Rousskov [Sat, 30 Jul 2016 19:55:15 +0000 (07:55 +1200)] 
Fix crash after rev.14735

7 years agoFix Certificate Validator buffer-overflow crashes Squid (commit r14757)
Christos Tsantilas [Fri, 29 Jul 2016 08:31:12 +0000 (11:31 +0300)] 
Fix Certificate Validator buffer-overflow crashes Squid (commit r14757)

- In the case of unexpected or timedout helper replies we must ignore the
  current message untill an eom found.

- Inside helperStatefulHandleRead, the current Helper::Xaction can be NULL
  in the case of unexpected helper reply.

This is a Measurement Factory Project

7 years agoCleanup: remove useless dead #include lines
Amos Jeffries [Wed, 27 Jul 2016 21:20:40 +0000 (09:20 +1200)] 
Cleanup: remove useless dead #include lines

7 years agoCleanup: sort stub_libsecurity
Amos Jeffries [Wed, 27 Jul 2016 21:16:35 +0000 (09:16 +1200)] 
Cleanup: sort stub_libsecurity

7 years agoTLS: do not hang when 'connector' fails
Amos Jeffries [Wed, 27 Jul 2016 12:24:50 +0000 (00:24 +1200)] 
TLS: do not hang when 'connector' fails

7 years agoSourceFormat Enforcement
Source Maintenance [Wed, 27 Jul 2016 12:12:14 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoCleanup: Move PeerConnector and BlindPeerConnector to libsecurity
Amos Jeffries [Wed, 27 Jul 2016 11:06:57 +0000 (23:06 +1200)] 
Cleanup: Move PeerConnector and BlindPeerConnector to libsecurity

Just namespace renaming and redux of USE_OPENSSL wrapped code sections.

7 years agoSquid segfault via Ftp::Client::readControlReply().
Christos Tsantilas [Wed, 27 Jul 2016 08:18:03 +0000 (11:18 +0300)] 
Squid segfault via Ftp::Client::readControlReply().

Ftp::Client::scheduleReadControlReply(), which may called from the
asynchronous start() or readControlReply()/handleControlReply()
handlers, does not check whether the control connection is still usable
before using it.

This is a Measurement Factory project.

7 years agoSourceFormat Enforcement
Source Maintenance [Mon, 25 Jul 2016 12:12:06 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoCertificate Validator buffer-overflow crashes Squid part2: fix 'make check' errors
Christos Tsantilas [Mon, 25 Jul 2016 11:24:12 +0000 (14:24 +0300)] 
Certificate Validator buffer-overflow crashes Squid part2: fix 'make check' errors

7 years agokerberos_ldap_group: support SSL/TLS used to connect to an LDAP server
Markus Moeller [Mon, 25 Jul 2016 10:59:47 +0000 (22:59 +1200)] 
kerberos_ldap_group: support SSL/TLS used to connect to an LDAP server

Also, apply code formatting

7 years agoCertificate Validator buffer-overflow crashes Squid
Christos Tsantilas [Mon, 25 Jul 2016 10:22:54 +0000 (13:22 +0300)] 
Certificate Validator buffer-overflow crashes Squid

Certain server certificates with a large chain and/or large certificates
(i.e. due to excessive amount of SAN entries) are producing helper requests and
replies which are larger than the 32KB limit set in src/helper.cc.

The major problem for squid is that the helper response should fit in the
helper read buffer. Currently squid starts with 4K request buffer and if
required may increase the buffer size up to 32K.

This patch:
  - Uses a constant-size read buffer for helpers and accumulates the helper
    response to Helper::Reply object.
  - Changes the HelperServerBase::requests list to hold list of the new
    Helper::Xaction class which holds pairs of Helper::Request and
    Helper::Reply objects
  - Modifies the Helper::Reply class to accumulate data and restricts the
    required memory allocations

This is a Measurement Factory project

7 years agoFix clang 'smpAware' overrides a member function but is not marked 'override'
Amos Jeffries [Sun, 24 Jul 2016 06:30:24 +0000 (18:30 +1200)] 
Fix clang 'smpAware' overrides a member function but is not marked 'override'

7 years agoCollapse internal revalidation requests (SMP-unaware caches).
Eduard Bagdasaryan [Sat, 23 Jul 2016 13:36:56 +0000 (01:36 +1200)] 
Collapse internal revalidation requests (SMP-unaware caches).

... also address Bug 4311 and partially address Bug 2833 and Bug 4471.

Extend collapsed_forwarding functionality to internal revalidation
requests. This implementation does not support Vary-controlled cache
objects and is limited to SMP-unaware caching environments, where each
Squid worker knows nothing about requests and caches handled by other
workers. However, it also lays critical groundwork for future SMP-aware
collapsed revalidation support.

Prior to these changes, multiple concurrent HTTP requests for the same
stale cached object always resulted in multiple internal revalidation
requests sent by Squid to the origin server. Those internal requests
were likely to result in multiple competing Squid cache updates, causing
cache misses and/or more internal revalidation requests, negating
collapsed forwarding savings.

Internal cache revalidation requests are collapsed if and only if
collapsed_forwarding is enabled. There is no option to control just
revalidation collapsing because there is no known use case for it.

* Public revalidation keys

Each Store entry has a unique key. Keys are used to find entries in the
Store (both already cached/swapped_out entries and not). Public keys are
normally tied to the request method and target URI. Same request
properties normally lead to the same public key, making cache hits
possible. If we were to calculate a public key for an internal
revalidation request, it would have been the same as the public key of
the stale cache entry being revalidated. Adding a revalidation response
to Store would have purged that being-revalidated cached entry, even if
the revalidation response itself was not cachable.

To avoid purging being-revalidated cached entries, the old code used
private keys for internal revalidation requests. Private keys are always
unique and cannot accidentally purge a public entry. On the other hand,
for concurrent [revalidation] requests to find the store entry to
collapse on, that store entry has to have a public key!

We resolved this conflict by adding "scope" to public keys:

* Regular/old public keys have default empty scope (that does not affect
  key generation). The code not dealing with collapsed revalidation
  continues to work as before. All entries stored in caches continue to
  have the same keys (with an empty scope).

* When collapsed forwarding is enabled, collapsable internal
  revalidation requests get public keys with a "revalidation" scope
  (that is fed to the MD5 hash when the key is generated). Such a
  revalidation request can find a matching store entry created by
  another revalidation request (and collapse on it), but cannot clash
  with the entry being revalidated (because that entry key is using a
  different [empty] scope).

This change not only enables collapsing of internal revalidation
requests within one worker, but opens the way for SMP-aware workers to
share information about collapsed revalidation requests, similar to how
those workers already share information about being-swapped-out cache
entries.

After receiving the revalidation response, each collapsed revalidation
request may call updateOnNotModified() to update the stale entry [with
the same revalidation response!]. Concurrent entry updates would have
wasted many resources, especially for disk-cached entries that support
header updates, and may have purged being-revalidated entries due to
locking conflicts among updating transactions. To minimize these
problems, we adjusted header and entry metadata updating logic to skip
the update if nothing have changed since the last update.

Also fixed Bug 4311: Collapsed forwarding deadlocks for SMP Squids using
SMP-unaware caches. Collapsed transactions stalled without getting a
response because they were waiting for the shared "transients" table
updates. The table was created by Store::Controller but then abandoned (not
updated) by SMP-unaware caches. Now, the transients table is not created
at all unless SMP-aware caches are present. This fix should also address
complaints about shared memory being used for Squid instances without
SMP-aware caches.

A combination of SMP-aware and SMP-unaware caches is still not supported
and is likely to stall collapsed transactions if they are enabled. Note
that, by default, the memory cache is SMP-aware in SMP environments.

7 years agoQuieten digest oversize warnings
Amos Jeffries [Sat, 23 Jul 2016 06:02:56 +0000 (18:02 +1200)] 
Quieten digest oversize warnings

7 years agoSourceFormat Enforcement
Source Maintenance [Sat, 23 Jul 2016 00:12:14 +0000 (00:12 +0000)] 
SourceFormat Enforcement

7 years agoFix some failed transactions not being logged.
Eduard Bagdasaryan [Fri, 22 Jul 2016 19:37:12 +0000 (07:37 +1200)] 
Fix some failed transactions not being logged.

There are situations when Squid logs nothing to access.log after an
[abnormal] transaction termination. Such "stealthy" transactions may be
a security risk and an accounting problem.

ClientHttpRequest is responsible for logging most transactions but that
object is created only after the HTTP request headers are successfully
parsed. Request header parsing errors may be detected and logged
appropriately, but the job handling the incoming transaction may
terminate for reasons outside the parsing code control (e.g., a job-
killing exception thrown when there are no request headers to start
parsing yet or when the job waits for more request headers to finishing
parsing).

This change adds access logging for three cases:

1. accept(2) system call errors (before ConnStateData job is created).

2. Unexpected ConnStateData job termination, when there is no
   ClientHttpRequest to log the failure.

3. Connections which send no bytes: these connections drain Squid
   resources and, hence, should be logged.
   TODO: make this behavior configurable because some browsers are known to
   routinely create such connections(and, hence, logging them may create
   too much noise in some environments).

7 years agoAdd stub for log/liblog symbols
Amos Jeffries [Fri, 22 Jul 2016 13:19:36 +0000 (01:19 +1200)] 
Add stub for log/liblog symbols

7 years agoAdd missing 'tls' option for cache_peer
Amos Jeffries [Fri, 22 Jul 2016 08:38:30 +0000 (20:38 +1200)] 
Add missing 'tls' option for cache_peer

7 years agoCleanup: remove XSTD_USE_LIBLTDL, which has not been needed in a long while.
Amos Jeffries [Wed, 20 Jul 2016 14:33:14 +0000 (02:33 +1200)] 
Cleanup: remove XSTD_USE_LIBLTDL, which has not been needed in a long while.

7 years agoRevert changes in rev.14726
Amos Jeffries [Mon, 18 Jul 2016 12:36:38 +0000 (00:36 +1200)] 
Revert changes in rev.14726

7 years agoCleanup: drop redundant parse buffer check
Eduard Bagdasaryan [Sun, 17 Jul 2016 09:03:05 +0000 (21:03 +1200)] 
Cleanup: drop redundant parse buffer check

7 years agoFix error: taking the absolute value of unsigned type after rev.14739
Amos Jeffries [Sat, 16 Jul 2016 11:13:00 +0000 (23:13 +1200)] 
Fix error: taking the absolute value of unsigned type after rev.14739

7 years agoSourceFormat Enforcement
Source Maintenance [Fri, 15 Jul 2016 18:12:18 +0000 (18:12 +0000)] 
SourceFormat Enforcement

7 years agomake the Downloader::CbDialer a CallDialer kid
Christos Tsantilas [Fri, 15 Jul 2016 14:06:44 +0000 (17:06 +0300)] 
make the Downloader::CbDialer a CallDialer kid

7 years agoremove XXX comments from PeerConnector related to Downloader: they are not valid...
Christos Tsantilas [Fri, 15 Jul 2016 13:28:48 +0000 (16:28 +0300)] 
remove XXX comments from PeerConnector related to Downloader: they are not valid any more

7 years agoCleanup: remove unused references to SquidList.h
Amos Jeffries [Fri, 15 Jul 2016 13:13:03 +0000 (01:13 +1200)] 
Cleanup: remove unused references to SquidList.h

7 years agocall setLogUri to set url if no adaptation is used
Christos Tsantilas [Fri, 15 Jul 2016 13:12:09 +0000 (16:12 +0300)] 
call setLogUri to set url if no adaptation is used

7 years agoCleanup: use std::queue for UFS file I/O queues
Amos Jeffries [Fri, 15 Jul 2016 13:09:18 +0000 (01:09 +1200)] 
Cleanup: use std::queue for UFS file I/O queues

7 years agoSquid-dev review comments by Alex and Amos
Christos Tsantilas [Fri, 15 Jul 2016 11:05:34 +0000 (14:05 +0300)] 
Squid-dev review comments by Alex and Amos

7 years agoCleanup: TunnelStateData switchToTunnel function
Amos Jeffries [Wed, 13 Jul 2016 12:59:17 +0000 (00:59 +1200)] 
Cleanup: TunnelStateData switchToTunnel function

7 years agoCleanup: PeerConnector session initialization method
Amos Jeffries [Wed, 13 Jul 2016 12:39:22 +0000 (00:39 +1200)] 
Cleanup: PeerConnector session initialization method

* rename initializeSsl() method to initializeTls()

* use SessionPointer instead of SessionPtr

* return value is best used in boolean expressions, so make it bool
  this also resolves some template issues with SessionPointer return type.

* rename the session parameter to serverSession which better documents what
  it is than 'ssl', and distinguishes it from clientSession in child methods
  which have to deal with both.

7 years agoFix error: 'storeDigestRegisterWithCacheManager' was not declared
Amos Jeffries [Wed, 13 Jul 2016 11:31:50 +0000 (23:31 +1200)] 
Fix error: 'storeDigestRegisterWithCacheManager' was not declared

7 years agoBug 4534: assertion failure in xcalloc when using many cache_dir
Amos Jeffries [Tue, 12 Jul 2016 16:15:51 +0000 (04:15 +1200)] 
Bug 4534: assertion failure in xcalloc when using many cache_dir

7 years agoDocumentation, polishing and fixes
Christos Tsantilas [Mon, 11 Jul 2016 15:34:28 +0000 (18:34 +0300)] 
Documentation, polishing and fixes

 - Add/fix basic documentation for Downloader and DownloaderContext classes
 - Move DownloaderContext class definition to Downloader.cc file
 - fix cbdata leaks inside DownloaderCotnext destructor, caused by simple typo
   mistake.
 - Do not cbdatalock the ClientHttpRequest object inside DownloaderContext.
   This class is responsible to hold the main pointer and finaly delete the
   ClientHttpRequest object.

7 years agoCleanup: Ssl::Create*() functions
Amos Jeffries [Mon, 11 Jul 2016 10:57:11 +0000 (22:57 +1200)] 
Cleanup: Ssl::Create*() functions

* return value is only used in boolean expressions, so make it bool

* pass Comm::ConnectionPointer instead of raw-FD value

7 years agobasic_db_auth: add support for unsalted SHA1 passwords
jltallon [Fri, 8 Jul 2016 12:30:01 +0000 (00:30 +1200)] 
basic_db_auth: add support for unsalted SHA1 passwords