]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
7 years agoFix two read-ahead problems related to delay pools (or lack of thereof).
Eduard Bagdasaryan [Fri, 3 Mar 2017 22:15:10 +0000 (15:15 -0700)] 
Fix two read-ahead problems related to delay pools (or lack of thereof).

1. Honor EOF on Squid-to-server connections with full read ahead buffers
   and no clients when --enable-delay-pools is used without any delay
   pools configured in squid.conf.

Since trunk r6150.

Squid delays reading from the server after buffering read_ahead_gap
bytes that are not yet sent to the client. A delayed read is normally
resumed after Squid sends more buffered bytes to the client. See
readAheadPolicyCanRead() and kickReads().

However, Squid was not resuming the delayed read after all Store clients
were gone. If quick_abort prevents Squid from immediately closing the
corresponding Squid-to-server connection, then the connection gets stuck
until read_timeout (15m), even if the server closes much sooner, --
without reading from the server, Squid cannot detect the connection
closure. The affected connections enter the CLOSE_WAIT state.

Kicking delayed read when the last client leaves fixes the problem. The
removal of any client, including the last one, may change
readAheadPolicyCanRead() answer and, hence, deserves a kickReads() call.

Why "without any delay pools configured in squid.conf"? When classic
(i.e., delay_pool_*) delay pools are configured, Squid kicks all delayed
reads every second. That periodic kicking is an old design bug, but it
resumes stuck reads when all Store clients are gone. Without classic
delay pools, there is no periodic kicking. This fix does not address
that old bug but removes Squid hidden dependence on its side effect.

Note that the Squid-to-server connections with full read-ahead buffers
still remain "stuck" if there are non-reading clients. There is nothing
Squid can do about them because we cannot reliably detect EOF without
reading at least one byte and such reading is not allowed by the read
ahead gap. In other words, non-reading clients still stall server
connections.

While fixing this, I moved all CheckQuickAbort() tests into
CheckQuickAbortIsReasonable() because we need a boolean function to
avoid kicking aborted entries and because the old separation was rather
awkward -- CheckQuickAbort() contained "reasonable" tests that were not
in CheckQuickAbortIsReasonable(). All the aborting tests and their order
were preserved during this move. The moved tests gained debugging.

According to the existing test order in CheckQuickAbortIsReasonable(),
the above problem can be caused by:

* non-private responses with a known content length
* non-private responses with unknown content length, having quick_abort_min
  set to -1 KB.

2. Honor read_ahead_gap with --disable-delay-pools.

Since trunk r13954.

This fix also addresses "Perhaps these two calls should both live
in MemObject" comment and eliminates existing code duplication.

7 years agoSourceFormat Enforcement
Source Maintenance [Fri, 3 Mar 2017 12:12:01 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoBug 4671 pt4: refactor Format::assemble()
Amos Jeffries [Fri, 3 Mar 2017 11:52:37 +0000 (00:52 +1300)] 
Bug 4671 pt4: refactor Format::assemble()

* replace the String local with an SBuf to get appendf()

* overdue removal of empty lines and '!= NULL' conditions

* reduce scope redux for many out assignments

* use sizeof(tmp) instead of '1024'

* Fixes many GCC 7 compile errors from snprintf() being called with a
  too-small buffer.

* update the for-loops in Adaptation::History to C++11 and produce output
  in an SBuf. Removing need for iterator typedef's and resolving more GCC 7
  warnings about too-small buffers for snprintf().

7 years agoBug 4671 pt3: remove limit on FTP realm strings
Amos Jeffries [Fri, 3 Mar 2017 11:41:07 +0000 (00:41 +1300)] 
Bug 4671 pt3: remove limit on FTP realm strings

Convert ftpRealm() from generating char* to SBuf. This fixes issues identified
by GCC 7 where the realm string may be longer than the available buffer and
gets truncated.
The size of the buffer was making the occurance rather rare, but it is still
possible.

7 years agoBug 4671 pt2: various GCC 7 compile errors
Amos Jeffries [Fri, 3 Mar 2017 11:36:02 +0000 (00:36 +1300)] 
Bug 4671 pt2: various GCC 7 compile errors

7 years agoBug 4657: delay IDENT until after PROXY protocol handling
Amos Jeffries [Thu, 2 Mar 2017 01:26:30 +0000 (14:26 +1300)] 
Bug 4657: delay IDENT until after PROXY protocol handling

7 years agoBug 4674: delay_parameters for class 3 and 4 assertion failed
Amos Jeffries [Wed, 1 Mar 2017 15:19:59 +0000 (04:19 +1300)] 
Bug 4674: delay_parameters for class 3 and 4 assertion failed

7 years agoCleanup: convert MemObject::_reply to ReplyPointer
Amos Jeffries [Wed, 1 Mar 2017 04:52:46 +0000 (17:52 +1300)] 
Cleanup: convert MemObject::_reply to ReplyPointer

7 years agoSourceFormat Enforcement
Source Maintenance [Tue, 28 Feb 2017 18:12:05 +0000 (18:12 +0000)] 
SourceFormat Enforcement

7 years agosquidclient: Fix missing error handling on PUT
Amos Jeffries [Tue, 28 Feb 2017 17:20:16 +0000 (06:20 +1300)] 
squidclient: Fix missing error handling on PUT

 Detected by Coverity Scan. Issue 1364710

7 years agoCleanup HttpStateData::peerSupportsConnectionPinning
Amos Jeffries [Mon, 27 Feb 2017 16:41:03 +0000 (05:41 +1300)] 
Cleanup HttpStateData::peerSupportsConnectionPinning

* move local variable lookups and creation as late as possible. This
  speeds up a bunch of cases where those variables are never needed.

* resolve an XXX about checking Proxy-Support header contents in an
  case-insensitive way, while also simplifying the test.

7 years agoCleanup: convert MemObject::request to Pointer
Amos Jeffries [Sun, 26 Feb 2017 10:24:15 +0000 (23:24 +1300)] 
Cleanup: convert MemObject::request to Pointer

7 years agoAdd missing return statements after self_destruct() in WCCP
Amos Jeffries [Thu, 23 Feb 2017 11:18:39 +0000 (00:18 +1300)] 
Add missing return statements after self_destruct() in WCCP

 Detected by Coverity Scan. Issues 136471213647131364718.

7 years agoAdd missing return statements after self_destruct()
Amos Jeffries [Thu, 23 Feb 2017 11:14:03 +0000 (00:14 +1300)] 
Add missing return statements after self_destruct()

 Detected by Coverity Scan. Issue 1364716.

7 years agoCleanup: convert class SBufStats to C++11 initialization
Amos Jeffries [Thu, 23 Feb 2017 11:11:13 +0000 (00:11 +1300)] 
Cleanup: convert class SBufStats to C++11 initialization

 ... and to Squid coding style layout.

This also resolves uninitialized variable in pinger issue detected by
Coverity Scan. Issue 1228696.

7 years agoAdd missing return statements after self_destruct() in UFS
Amos Jeffries [Thu, 23 Feb 2017 10:46:27 +0000 (23:46 +1300)] 
Add missing return statements after self_destruct() in UFS

 Detected by Coverity Scan. Issues 11542221154223.

7 years agoFix typ in rev.15070
Amos Jeffries [Thu, 23 Feb 2017 10:44:48 +0000 (23:44 +1300)] 
Fix typ in rev.15070

7 years agoAdd missing return statements after self_destruct() in rock config
Amos Jeffries [Thu, 23 Feb 2017 10:40:27 +0000 (23:40 +1300)] 
Add missing return statements after self_destruct() in rock config

  Detected by Coverity Scan. Issues 115421911542201154221.

------------- This line and the following will be ignored --------------

modified:
  src/fs/rock/RockSwapDir.cc

7 years agoAdd missing return statements after self_destruct()
Amos Jeffries [Thu, 23 Feb 2017 10:36:00 +0000 (23:36 +1300)] 
Add missing return statements after self_destruct()

 Detected by Coverity Scan. Issue 1401397

7 years agoAdd missing return statements after self_destruct()
Amos Jeffries [Thu, 23 Feb 2017 10:29:11 +0000 (23:29 +1300)] 
Add missing return statements after self_destruct()

 Detected by Coverity Scan. Issue 1364728.

7 years agoFix another Must(!= NULL) coverity issue.
Amos Jeffries [Thu, 23 Feb 2017 10:02:10 +0000 (23:02 +1300)] 
Fix another Must(!= NULL) coverity issue.

The issue is that Coverity Scan gets confused by implicit casting of NULL
to a Pointer into thinking that 'true' comparison is possible when NULL
is involved. The != should still compile to the correct checks.

 Coverity Scan issue 1364725.

7 years agoRemove some NULL references from adaptation/icap/ModXact.cc
Amos Jeffries [Thu, 23 Feb 2017 03:50:31 +0000 (16:50 +1300)] 
Remove some NULL references from adaptation/icap/ModXact.cc

This may resolve one odd false-positive by Coverity. Gets rid of some NULL anyhow if not.

7 years agoCleanup: convert SBuf to C++11 initialization
Amos Jeffries [Wed, 22 Feb 2017 17:39:44 +0000 (06:39 +1300)] 
Cleanup: convert SBuf to C++11 initialization

This should resolve many Coverity uninitialized member warnings
caused by the SBuf stub linked to pinger helper being confused
with the sbuf/libsbuf.la SBuf constructor definition.

7 years agoAdd missing include after rev.15059
Amos Jeffries [Wed, 22 Feb 2017 04:11:28 +0000 (17:11 +1300)] 
Add missing include after rev.15059

7 years agoFixed 'make check' to work with clang after r15057.
Alex Rousskov [Tue, 21 Feb 2017 16:32:01 +0000 (09:32 -0700)] 
Fixed 'make check' to work with clang after r15057.

7 years agoFixed one more type conversion error in r15057.
Alex Rousskov [Mon, 20 Feb 2017 22:23:02 +0000 (15:23 -0700)] 
Fixed one more type conversion error in r15057.

7 years agoFixed compilation and type conversion errors in r15057.
Alex Rousskov [Mon, 20 Feb 2017 17:41:41 +0000 (10:41 -0700)] 
Fixed compilation and type conversion errors in r15057.

7 years agoEnable https:// URL outgoing support with GnuTLS
Amos Jeffries [Mon, 20 Feb 2017 13:10:21 +0000 (02:10 +1300)] 
Enable https:// URL outgoing support with GnuTLS

7 years agoTLS: refactor Security::ContextPointer to a std::shared_ptr
Amos Jeffries [Mon, 20 Feb 2017 12:51:03 +0000 (01:51 +1300)] 
TLS: refactor Security::ContextPointer to a std::shared_ptr

These pointers now use the same construction pattern tested out with
Security::SessionPointer.

It also fixes a reference counting bug in GnuTLS code paths where the
PeerConnector::initialize() method would be passed a temporary Pointer
and thus free the context/credentials before it was used by the session
verify logics.

7 years agoSync with v5 rev.15058
Amos Jeffries [Mon, 20 Feb 2017 06:37:16 +0000 (19:37 +1300)] 
Sync with v5 rev.15058

7 years agoSourceLayout: move HttpMsgParseState into Http::Message class
Amos Jeffries [Mon, 20 Feb 2017 04:56:00 +0000 (17:56 +1300)] 
SourceLayout: move HttpMsgParseState into Http::Message class

7 years agoAdd response delay pools feature for Squid-to-client speed limiting.
Eduard Bagdasaryan [Sun, 19 Feb 2017 17:13:27 +0000 (06:13 +1300)] 
Add response delay pools feature for Squid-to-client speed limiting.

The feature restricts Squid-to-client bandwidth only.  It applies to
both cache hits and misses.

  * Rationale *

  This may be useful for specific response(s) bandwidth limiting.
  There are situations when doing this is hardly possible
  (or impossible) by means of netfilter/iptables operating with
  TCP/IP packets and IP addresses information for filtering. In other
  words, sometimes it is problematic to 'extract' a single response from
  TCP/IP data flow at system level. For example, a single Squid-to-client
  TCP connection can transmit multiple responses (persistent connections,
  pipelining or HTTP/2 connection multiplexing) or be encrypted
  (HTTPS proxy mode).

  * Description *

  When Squid starts delivering the final HTTP response to a client,
  Squid checks response_delay_pool_access rules (supporting fast ACLs
  only), in the order they were declared. The first rule with a
  matching ACL wins.  If (and only if) an "allow" rule won, Squid
  assigns the response to the corresponding named delay pool.

  If a response is assigned to a delay pool, the response becomes
  subject to the configured bucket and aggregate bandwidth limits of
  that pool, similar to the current "class 2" server-side delay pools,
  but with a brand new, dedicated "individual" filled bucket assigned to
  the matched response.

  The new feature serves the same purpose as the existing client-side
  pools: both features limit Squid-to-client bandwidth. Their common
  interface was placed into a new base BandwidthBucket class.  The
  difference is that client-side pools do not aggregate clients and
  always use one bucket per client IP. It is possible that a response
  becomes a subject of both these pools. In such situations only matched
  response delay pool will be used for Squid-to-client speed limiting.

  * Limitations *

  The accurate SMP support (with the aggregate bucket shared among
  workers) is outside this patch scope. In SMP configurations,
  Squid should automatically divide the aggregate_speed_limit and
  max_aggregate_size values among the configured number of Squid
  workers.

  * Also: *

  Fixed ClientDelayConfig which did not perform cleanup on
  destruction, causing memory problems detected by Valgrind. It was not
  possible to fix this with minimal changes because of linker problems
  with SquidConfig while checking with test-builds.sh. So I had
  to refactor ClientDelayConfig module, separating configuration code
  (old ClientDelayConfig class) from configured data (a new
  ClientDelayPools class) and minimizing dependencies with SquidConfig.

7 years agoSourceFormat Enforcement
Source Maintenance [Sun, 19 Feb 2017 06:12:04 +0000 (06:12 +0000)] 
SourceFormat Enforcement

7 years agoNative FTP relay: NAT and TPROXY interception fixes
Alexander Gozman [Sun, 19 Feb 2017 05:19:06 +0000 (18:19 +1300)] 
Native FTP relay: NAT and TPROXY interception fixes

7 years agoCleanup: convert DNS nameserver list from wordlist to SBufList
Amos Jeffries [Sun, 19 Feb 2017 04:18:27 +0000 (17:18 +1300)] 
Cleanup: convert DNS nameserver list from wordlist to SBufList

7 years agoext_kerberos_ldap_group_acl: fix unused value warnings
Amos Jeffries [Sat, 18 Feb 2017 18:05:57 +0000 (07:05 +1300)] 
ext_kerberos_ldap_group_acl: fix unused value warnings

 Detected by Coverity Scan. Issues 1364748 and 1364749.

7 years agoCleanup: convert main DNS classes to C++11 initialization
Amos Jeffries [Fri, 17 Feb 2017 23:34:49 +0000 (12:34 +1300)] 
Cleanup: convert main DNS classes to C++11 initialization

7 years agoCheck that -k argument is provided before trying to use it.
Amos Jeffries [Fri, 17 Feb 2017 04:53:00 +0000 (17:53 +1300)] 
Check that -k argument is provided before trying to use it.

 Detected by Coverity Scan. Issue 1364726.

7 years agoSourceFormat Enforcement
Source Maintenance [Thu, 16 Feb 2017 12:12:17 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoSourceLayout: move HttpMsg into libhttp as Http::Message
Amos Jeffries [Thu, 16 Feb 2017 11:51:56 +0000 (00:51 +1300)] 
SourceLayout: move HttpMsg into libhttp as Http::Message

* move files and rename the class

* add http/forward.h entries for Message and MessagePointer
 (replacing the HttpMsg::Pointer typedef)

* remove unnecessary includes for HttpMsg.h and HttpRequest.h

Also, some minor cleanup within the class files reducing debugs()
duplication, function/method coding style and doxtgen'ating some
code comments.

7 years agoSourceFormat Enforcement
Source Maintenance [Thu, 16 Feb 2017 00:12:17 +0000 (00:12 +0000)] 
SourceFormat Enforcement

7 years agoFix empty header handling in Ecap::HeaderRep::hasAny().
Eduard Bagdasaryan [Wed, 15 Feb 2017 18:54:02 +0000 (11:54 -0700)] 
Fix empty header handling in Ecap::HeaderRep::hasAny().

The method returned false for present but empty "unknown" headers.
The fixed version is also faster, closing an old optimization XXX.

7 years agoCleanup: refcounting HttpRequest member of class ErrorState
Amos Jeffries [Wed, 15 Feb 2017 03:10:55 +0000 (16:10 +1300)] 
Cleanup: refcounting HttpRequest member of class ErrorState

Replace the manual lock/unlock of ErrorState::request with a Pointer.

Replace the parameter of ErrorState::NewForwarding to acccept a Pointer
and removes an assert() by absorbing the if(request) logic from the caller.

Also, some whitespace, NULL and HERE removals.

7 years agoCleanup: convert class ErrorState to C++11 initilization
Amos Jeffries [Tue, 14 Feb 2017 19:15:23 +0000 (08:15 +1300)] 
Cleanup: convert class ErrorState to C++11 initilization

7 years agoCleanup: convert class MessageSizes to C++11 initialization
Amos Jeffries [Tue, 14 Feb 2017 10:16:10 +0000 (23:16 +1300)] 
Cleanup: convert class MessageSizes to C++11 initialization

7 years agoDe-duplicate the ContextPointer creation code
Amos Jeffries [Tue, 14 Feb 2017 09:56:34 +0000 (22:56 +1300)] 
De-duplicate the ContextPointer creation code

Making the actual raw-pointer to Pointer conversion and lambda logic
into a protected method shared by both classes creatign ContextPointer.

Also improve debug a bit for libsecurity shared_ptr.

7 years agoFix memory leak and parse handling error introduced by r15024.
Eduard Bagdasaryan [Tue, 14 Feb 2017 02:03:27 +0000 (15:03 +1300)] 
Fix memory leak and parse handling error introduced by r15024.

* Do not leak Note::Value::Value::valueFormat.
* Throw if annotation value parsing failures.

Detected by Coverity Scan:
 * CID 1399758:  Error handling issues (CHECKED_RETURN)
 * CID 1399759:  Resource leaks (CTOR_DTOR_LEAK)

7 years agoBetter fix for bug 4663
Amos Jeffries [Sun, 12 Feb 2017 09:33:47 +0000 (22:33 +1300)] 
Better fix for bug 4663

7 years agoFix missing CRLF on FTP timeout ABORT commands
Amos Jeffries [Sun, 12 Feb 2017 02:33:40 +0000 (15:33 +1300)] 
Fix missing CRLF on FTP timeout ABORT commands

7 years agoBug 4663: GCC compile errors with optimization level -O3
Amos Jeffries [Sun, 12 Feb 2017 02:25:16 +0000 (15:25 +1300)] 
Bug 4663: GCC compile errors with optimization level -O3

7 years agoTLS: refactor Security::ContextPointer to a std::shared_ptr
Amos Jeffries [Fri, 10 Feb 2017 13:35:05 +0000 (02:35 +1300)] 
TLS: refactor Security::ContextPointer to a std::shared_ptr

These pointers now use the same construction pattern tested out with
Security::SessionPointer.

It also fixes a reference counting bug in GnuTLS code paths where the
PeerConnector::initialize() method would be passed a temporary Pointer
and thus free the context/credentials before it was used by the session
verify logics.

7 years agodigest_ldap_auth: Add -r option to clamp the realm to a fixed value
Emmanuel Fuste [Wed, 8 Feb 2017 19:12:00 +0000 (08:12 +1300)] 
digest_ldap_auth: Add -r option to clamp the realm to a fixed value

Some historic Digest Auth implementations do not include the realm in the
digest password attribute. The password is effectively stored as "HA1"
instead of "REALM:HA1".

The realm cannot simply be ignored due to:
 1) the realm is both the salting value used within the hash and the
scope limitation on what inputs from HTTP are used to compare against
the A1, and
 2) Squid does not itself verify the realm received was the one offered
and leaves the comparison to the backend system. There is some
possibility the authentication system is using multiple security realms
and Squids realm string is just an offer.

Not having realm tied to the credentials in the backend storage leaves
this particular helper with no other option but to trust the realm sent
(probably) over clear-text by any client/attacker actually matches the
salting. That allows remote senders to manipulate the realm string they
send to perform a collision attack against the stored password.
 They no longer have to find and prove knowledge of the password. But
just find a collision for its hash vs arbitrary realm strings.

Old Digest systems are not the safest things to begin with. They also
tend to use MD5 hashing which was the only one available for many years
and relatively easy to find collisions for.

To resolve all these problems allow the -l parameter to accept an empty
string ('-l "" ') when the -r option provides a fixed realm.

Also, fix several typos in the help text.

7 years agoFix uninitialized variable in libadaptation
Amos Jeffries [Wed, 8 Feb 2017 17:57:26 +0000 (06:57 +1300)] 
Fix uninitialized variable in libadaptation

The grokBool() parse method does not alter the bool parameter on invalid
inputs. This results in encrypt local variabel bein gused uninitialized.

7 years agoGCC7: raise FTP Gateway CTRL channel buffer to 16KB
Amos Jeffries [Tue, 7 Feb 2017 08:20:39 +0000 (21:20 +1300)] 
GCC7: raise FTP Gateway CTRL channel buffer to 16KB

Fixes
 error: %s directive output may be truncated writing up to 8191 bytes
        into a region of size 1019
 note: snprintf output between 8 and 8199 bytes into a destination of
       size 1024

7 years agoBump SSL client on [more] errors encountered before ssl_bump evaluation
Christos Tsantilas [Mon, 6 Feb 2017 16:52:12 +0000 (18:52 +0200)] 
Bump SSL client on [more] errors encountered before ssl_bump evaluation

... such as ERR_ACCESS_DENIED with HTTP/403 Forbidden triggered by an
http_access deny rule match.

The old code allowed ssl_bump step1 rules to be evaluated in the
presence of an error. An ssl_bump splicing decision would then trigger
the useless "send the error to the client now" processing logic instead
of going down the "to serve an error, bump the client first" path.

Furthermore, the ssl_bump evaluation result itself could be surprising
to the admin because ssl_bump (and most other) rules are not meant to be
evaluated for a transaction in an error state. This complicated triage.

Also polished an important comment to clarify that we want to bump on
error if (and only if) the SslBump feature is applicable to the failed
transaction (i.e., if the ssl_bump rules would have been evaluated if
there were no prior errors). The old comment could have been
misinterpreted that ssl_bump rules must be evaluated to allow an
"ssl_bump splice" match to hide the error.

This is a Measurement Factory project.

7 years agoPrep for 4.0.18
Amos Jeffries [Sun, 5 Feb 2017 21:07:43 +0000 (10:07 +1300)] 
Prep for 4.0.18

7 years agoRe-enable https:// URL handling after merges
Amos Jeffries [Sun, 5 Feb 2017 17:20:04 +0000 (06:20 +1300)] 
Re-enable https:// URL handling after merges

7 years agoSync from v5 r15034
Amos Jeffries [Sun, 5 Feb 2017 16:44:17 +0000 (05:44 +1300)] 
Sync from v5 r15034

7 years agoFix 'warning: unused local' after rev.15025
Amos Jeffries [Sun, 5 Feb 2017 09:40:21 +0000 (22:40 +1300)] 
Fix 'warning: unused local' after rev.15025

7 years agoSourceFormat Enforcement
Source Maintenance [Sun, 5 Feb 2017 06:12:19 +0000 (06:12 +0000)] 
SourceFormat Enforcement

7 years agoCrypto-NG: initial GnuTLS support for encrypted server connections
Amos Jeffries [Sun, 5 Feb 2017 05:57:32 +0000 (18:57 +1300)] 
Crypto-NG: initial GnuTLS support for encrypted server connections

Make significant changes to how the options= config settings are
handled internally since GnuTLS does not expose the priority_t
implementation details like OpenSSL. They are also applied to the
session object instead of to the context.

The Security::SessionPointer is converted to std::shared_ptr. This is
required because GnuTLS does not expose the locking like OpenSSL. Since
we store the SessionPointer to fde::Table::ssl we can always access it
from there one way or another and there is actually no need for OpenSSL
locking sessions now.

Most of the remaining session lifecycle logic is moved to
security/Session.* and given a generic API. Only some client-connection
and SSL-Bump related setup remains in ssl/.

A fair amount more debug is added along with some text changes doing
s/SSL/TLS/ in code comments and debug outputs.

7 years agoCleanup: remove unsused fd_debug_t and fdd_table
Amos Jeffries [Sat, 4 Feb 2017 16:30:49 +0000 (05:30 +1300)] 
Cleanup: remove unsused fd_debug_t and fdd_table

This tables used to store the file and line location where each FD was
closed from, but never read for any reports or logs.

Make the cache.log debugging for comm_close display that information
instead of storing it in memory. This way when debug of the comm layer
is enabled the closure information for each FD open/close cycle is
recorded and not just the place of last closure.

Also we save a few hundred KB of memory this table was using and all the
CPU cycles used to maintain it when debugging was not needed.

7 years agoCleanup: update class fde and _fde_disk to C++11
Amos Jeffries [Sat, 4 Feb 2017 11:16:36 +0000 (00:16 +1300)] 
Cleanup: update class fde and _fde_disk to C++11

This update moves the initialization of most class members into default
initizliation values. So clear() can be optimized to a fast emplace
initialization by the compiler and removing the need for memset().

NP: implicit initialization of function pointers and char* arrays is not
supported by C++11. So use of default constructor is still required for now.

Also,
- replace internal uses of fd_table macro with fde::Table.
- replace use of NULL with nullptr
- update some method declaratiosn to current coding style
- improve inline ability for noteUse() method
- const correctness for several inline methods
- documentation updates

7 years agoAdd debugs for loading the system CA set
Amos Jeffries [Tue, 31 Jan 2017 15:30:19 +0000 (04:30 +1300)] 
Add debugs for loading the system CA set

7 years agoFix crash when configuring with invalid delay_parameters restore value.
Alex Rousskov [Tue, 31 Jan 2017 00:46:31 +0000 (17:46 -0700)] 
Fix crash when configuring with invalid delay_parameters restore value.

... like none/none. Introduced in r13701 which fixed another, much
bigger delay_parameters parsing bug.

TODO: Reject all invalid input, including restore/max of "-/100".

TODO: Fix misleading/wrong associated error messages. For example:
  ERROR: invalid delay rate 'none/none'. Expecting restore/max or 'none'
  ERROR: restore rate in '1/none' is not a number.

7 years agoSourceFormat Enforcement
Source Maintenance [Tue, 31 Jan 2017 00:12:18 +0000 (00:12 +0000)] 
SourceFormat Enforcement

7 years agoTwo new ACLs implemented: annotate_transaction and annotate_client part3
Christos Tsantilas [Mon, 30 Jan 2017 18:10:15 +0000 (20:10 +0200)] 
Two new ACLs implemented: annotate_transaction and annotate_client part3

Fixes annotate_client and annotate_transaction acls documentation in
cf.data.pre

7 years agoTwo new ACLs implemented: annotate_transaction and annotate_client part2
Eduard Bagdasaryan [Mon, 30 Jan 2017 14:00:24 +0000 (16:00 +0200)] 
Two new ACLs implemented: annotate_transaction and annotate_client part2

Add forgotten new files:
 src/acl/AnnotateClient.cc
 src/acl/AnnotateClient.h
 src/acl/AnnotateTransaction.cc
 src/acl/AnnotateTransaction.h
 src/acl/AnnotationData.cc
 src/acl/AnnotationData.h

7 years agoFix Auth::UserRequest::denyMessage() misuse.
Eduard Bagdasaryan [Mon, 30 Jan 2017 13:01:33 +0000 (15:01 +0200)] 
Fix Auth::UserRequest::denyMessage() misuse.

This method was improperly used in contexts where actually
Auth::UserRequest::setDenyMessage() expected. Probably the reason was
that both denyMessage() and getDenyMessage() were not constant,
provoking such 'misuse'.

Also placed some common code into UserRequest::denyMessageFromHelper(),
eliminating code duplication. Though there are still many places
where code is duplicated inside auth/ntlm/UserRequest.cc and
auth/negotiate/UserRequest.cc.

7 years agoauthor: Eduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Christos Tsantilas [Mon, 30 Jan 2017 12:46:15 +0000 (14:46 +0200)] 
author: Eduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Two new ACLs implemented: annotate_transaction and annotate_client.

Both ACLs always match and are useful for their side effect, immediately
adding a key-value pair to the current transaction annotation
(annotate_transaction) or to the current client-to-Squid connection
annotation (annotate_client).  Connection annotations are propagated to
the current and all future master transactions on the annotated
connection. Before this patch only 'clt_conn_tag' annotation tag could
be used for a connection annotation.

To reuse the existing notes parsing code, I had to refactor Note, Notes
and NotePairs classes:

* Made data members private and adjusted to follow 'rule of three'.
  Having public assess to containers with pointers may cause memory
  problems: for example ExternalACLEntry::update() called directly
  notes.entries.clear() without deleting the pointers.
* None-fatal check for 'special' characters inside note name.
* Used SBufs instead of Strings and const char* where possible.
* Adjusted ACLNoteStrategy::matchNotes() to avoid 'expanding quoted values'
  code duplication inside

Also fixed acl quoted flag parameters syntax. The old code improperly
required quoting both flag and its parameter, e.g., "-m= ," whereas
only parameter should be quoted: -m=" ,".

Also moved UpdateRequestNotes() from Notes.cc to HttpRequest.cc to
resolve dependency problems while bulding unit tests.

TODO: transaction annotation matching code (ACLNoteData) performs
parsing in its own way, using ACLStringData::parse(), lacking special
characters/reserved keywords checks. Consider reusing the existing
Notes parsing code instead.

7 years agoUse default copy constructor and assignment
Amos Jeffries [Sat, 28 Jan 2017 10:08:09 +0000 (23:08 +1300)] 
Use default copy constructor and assignment

This fixes one bug in PeerOptions::flags handling

7 years agoBug 4661: compile error 'warning: _XPG4_2 redefined' with GCC on Solaris 10
Amos Jeffries [Sat, 28 Jan 2017 08:51:25 +0000 (21:51 +1300)] 
Bug 4661: compile error 'warning: _XPG4_2 redefined' with GCC on Solaris 10

7 years agoFix langpack generation after 'trunk' branch deprecated
Amos Jeffries [Sat, 28 Jan 2017 04:13:06 +0000 (17:13 +1300)] 
Fix langpack generation after 'trunk' branch deprecated

7 years agoPrep for 3.5.24
Amos Jeffries [Sat, 28 Jan 2017 03:35:32 +0000 (16:35 +1300)] 
Prep for 3.5.24

7 years agoSSLv2 records force SslBump bumping despite a matching step2 peek rule.
Christos Tsantilas [Thu, 26 Jan 2017 16:22:30 +0000 (18:22 +0200)] 
SSLv2 records force SslBump bumping despite a matching step2 peek rule.

If Squid receives a valid TLS Hello encapsulated into ancient SSLv2
records (observed on Solaris 10), the old code ignored the step2 peek
decision and bumped the transaction instead.
Now Squid peeks (or stares) at the origin server as configured, even
after detecting (and parsing) SSLv2 records.

This is a Measurement Factory project.

7 years agoComplain about malformed 64bit header values, not the valid ones.
Alex Rousskov [Wed, 25 Jan 2017 22:29:03 +0000 (15:29 -0700)] 
Complain about malformed 64bit header values, not the valid ones.

I added this regression in r14819, apparently confused by my own
unfortunate "bad is true" httpHeaderNoteParsedEntry(error) API.

7 years agoBug 4636: assertion failed: client_side.cc:1448: 'byteCount > 0 && byteCount <= inBuf...
Amos Jeffries [Wed, 25 Jan 2017 03:18:03 +0000 (16:18 +1300)] 
Bug 4636: assertion failed: client_side.cc:1448: 'byteCount > 0 && byteCount <= inBuf.length()'

7 years agor15014: fix more "make distcheck" issues
Christos Tsantilas [Tue, 24 Jan 2017 19:49:32 +0000 (21:49 +0200)] 
r15014: fix more "make distcheck" issues

7 years agor15014: fix build issue on fedora-22 and FreeBSD-10/clang
Christos Tsantilas [Tue, 24 Jan 2017 17:16:56 +0000 (19:16 +0200)] 
r15014: fix build issue on fedora-22 and FreeBSD-10/clang

7 years agoSourceFormat Enforcement
Source Maintenance [Tue, 24 Jan 2017 12:12:03 +0000 (12:12 +0000)] 
SourceFormat Enforcement

7 years agoMitigate DoS attacks that use client-initiated SSL/TLS renegotiation.
Christos Tsantilas [Tue, 24 Jan 2017 12:09:25 +0000 (14:09 +0200)] 
Mitigate DoS attacks that use client-initiated SSL/TLS renegotiation.

There is a well-known DoS attack using client-initiated SSL/TLS
renegotiation. The severety or uniqueness of this attack method
is disputed, but many believe it is serious/real.
There is even a (disputed) CVE 2011-1473:
    https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-1473

The old Squid code tried to disable client-initiated renegotiation, but
it did not work reliably (or at all), depending on Squid version, due
to OpenSSL API changes and conflicting SslBump callbacks. That
code is now removed and client-initiated renegotiations are allowed.

With this change, Squid aborts the TLS connection, with a level-1 ERROR
message if the rate of client-initiated renegotiate requests exceeds
5 requests in 10 seconds (approximately). This protection and the rate
limit are currently hard-coded but the rate is not expected to be
exceeded under normal circumstances.

This is a Measurement Factory project.

7 years agoPolishing updates from audit
Amos Jeffries [Tue, 24 Jan 2017 10:04:04 +0000 (23:04 +1300)] 
Polishing updates from audit

7 years agoFix some spelling mistakes
FredB [Tue, 24 Jan 2017 09:10:33 +0000 (22:10 +1300)] 
Fix some spelling mistakes

7 years agoCleanup: convert Delay Pool classes to MEMPROXY
Amos Jeffries [Tue, 24 Jan 2017 09:06:00 +0000 (22:06 +1300)] 
Cleanup: convert Delay Pool classes to MEMPROXY

7 years agoUpdate stub_libsecurity after Security::PeerOptions changes
root [Wed, 18 Jan 2017 18:44:37 +0000 (07:44 +1300)] 
Update stub_libsecurity after Security::PeerOptions changes

7 years agoBug 4610: fix 'Assigning a negative value to an implicit unsigned bitfield' on Solaris 11
Stefan Kruger [Tue, 17 Jan 2017 19:29:06 +0000 (08:29 +1300)] 
Bug 4610: fix 'Assigning a negative value to an implicit unsigned bitfield' on Solaris 11

7 years agoMake ParsedOptions a std::shared_ptr to reduce re-parsing
Amos Jeffries [Tue, 17 Jan 2017 13:55:33 +0000 (02:55 +1300)] 
Make ParsedOptions a std::shared_ptr to reduce re-parsing

7 years agoInitialize options= in all cases
Amos Jeffries [Tue, 17 Jan 2017 04:31:41 +0000 (17:31 +1300)] 
Initialize options= in all cases

Since we now have long and ptr in different builds we cannot rely on the
default constructor always being correct.

Adjust the parseOptions() method to handle empty options= silently for
OpenSSL buidls (like GnutTLS builds did already) and use it to initialize
the parsedOptions member.

7 years agoRename SessionClose to SessionSendGoodbye
Amos Jeffries [Mon, 16 Jan 2017 15:18:07 +0000 (04:18 +1300)] 
Rename SessionClose to SessionSendGoodbye

... and remove FD related things, which are no longer needed

7 years agoUpdate to options= after audit
Amos Jeffries [Mon, 16 Jan 2017 12:31:25 +0000 (01:31 +1300)] 
Update to options= after audit

7 years agoFix "Source and destination overlap in memcpy" Valgrind errors
Eduard Bagdasaryan [Sun, 15 Jan 2017 17:35:43 +0000 (06:35 +1300)] 
Fix "Source and destination overlap in memcpy" Valgrind errors

Before this patch, source and destination arguments in
log_quoted_string() could point to the same static memory area, causing
multiple Valgrind-reported errors. Fixed by creating another buffer to
store quoted-processed output string.

7 years agoReduce debugs in tls_write_method
Amos Jeffries [Sun, 15 Jan 2017 13:50:41 +0000 (02:50 +1300)] 
Reduce debugs in tls_write_method

7 years agoReduce debugs in tls_read_method
Amos Jeffries [Sun, 15 Jan 2017 13:50:10 +0000 (02:50 +1300)] 
Reduce debugs in tls_read_method

7 years agoReset TLS session unconditionally on PeerConnector errors
Amos Jeffries [Sun, 15 Jan 2017 11:33:10 +0000 (00:33 +1300)] 
Reset TLS session unconditionally on PeerConnector errors

The session state cleanup should be done regardless of library.

GnuTLS crash was the result of a bug elsewhere which is now fixed. So
remove mention of that.

7 years agoFix SessionClose when OpenSSl and GnuTLS are both linked
Amos Jeffries [Sun, 15 Jan 2017 11:31:22 +0000 (00:31 +1300)] 
Fix SessionClose when OpenSSl and GnuTLS are both linked

7 years agoFix compile error after debugs shuffle
Amos Jeffries [Sat, 14 Jan 2017 16:52:03 +0000 (05:52 +1300)] 
Fix compile error after debugs shuffle

7 years agoFix spelling error and polish some debugs
Amos Jeffries [Sat, 14 Jan 2017 15:47:45 +0000 (04:47 +1300)] 
Fix spelling error and polish some debugs

7 years agoEnable https:// URLs
Amos Jeffries [Sat, 14 Jan 2017 15:32:48 +0000 (04:32 +1300)] 
Enable https:// URLs

7 years agoMove handshaek IN/OUT debug to avoid 'Error' wording
Amos Jeffries [Sat, 14 Jan 2017 15:32:11 +0000 (04:32 +1300)] 
Move handshaek IN/OUT debug to avoid 'Error' wording

7 years agoMake GnuTLS handshake non-blocking
Amos Jeffries [Sat, 14 Jan 2017 14:58:59 +0000 (03:58 +1300)] 
Make GnuTLS handshake non-blocking