Commit Graph

2122 Commits

Author SHA1 Message Date
bda1c5d55d Fix use-after-free in buffer.c
The fix to MXS-1338 added a bug where the buffer objects were freed after
the shared buffer was freed.
2017-08-02 17:55:35 +03:00
63b16243e7 MXS-1338: Fix memory leak of after buffer cloning
When a buffer is cloned and then the original buffer parsed and freed, the
freeing of the cloned buffer will not release the memory that was
allocated when the original buffer is parsed.

This is a side-effect of how the buffer objects are stored in the buffer
and not in the shared memory buffer. The creation of a buffer object after
cloning will cause the buffer object to be lost as the cloned buffer
didn't have a pointer to the buffer object that was created later.

By moving the buffer objects into the shared memory buffer, the memory
leak is fixed.
2017-08-02 11:09:49 +03:00
f76e4cd61d Fix GCC 7 and OpenSSL 1.1 build failures
Fedora 26 and Debian 9 have both GCC 7 and OpenSSL 1.1. These fixes add
support for the newer versions of these libraries.
2017-07-24 10:38:47 +03:00
07a5cba2de MXS-1319: Set SQL_MODE for all internal connections
When an internal connection is created, the SQL_MODE of the connection
should be set to a known default. The empty SQL_MODE allows consistent
functionality for all backend server versions.
2017-07-18 11:21:33 +03:00
9752068444 MXS-1318: Use certificate chains instead of individual files
Using SSL_CTX_use_certificate_chain_file instead of
SSL_CTX_use_certificate_file allows the use of certificate chains. This is
the method that the OpenSSL documentation recommends:

https://wiki.openssl.org/index.php/Manual%3ASSL_CTX_use_certificate%283%29
2017-07-18 10:07:41 +03:00
f3e98745bd MXS-1313: Fix updating of server character sets
The server character set is now updated every time a connection is created
with mxs_mysql_real_connect.
2017-07-07 14:52:15 +03:00
322fae8326 Add wrapper functions for buffer and original IV access
Added functions for accessing the buffer and original IV. This hides the
changes introduced in OpenSSL 1.1.
2017-06-30 10:46:05 +03:00
a47d4c40f5 Abstract EVP cipher context creation
The EVP_CIPHER_CTX is now created inside a wrapper function to add support
for OpenSSL 1.1. Also fixed improper use of the EVP_CIPHER_CTX internals
in binlogrouter.
2017-06-30 10:46:04 +03:00
469b432ebe Detect and handle OpenSSL 1.1
OpenSSL 1.1 supports most of the native threading libraries, including
pthread. This means that only versions before 1.1 need the thread handling
code.
2017-06-30 10:42:20 +03:00
2bc5188dae MXS-1304: Don't null-terminate buffers in gw_str_xor
The gw_str_xor function is used only for doing XOR operations on binary
buffers.
2017-06-28 11:36:17 +03:00
dc849d1c0f MXS-1291: Attempt to bind on 0.0.0.0 when :: fails
If binding on the IPv6 all interfaces address fails, MaxScale will attempt
to bind on the IPv4 address.
2017-06-27 21:27:20 +03:00
cd09e65714 MXS-1296: Always use a case-insensitive parser
The two cases where the case-sensitive parser functions were used don't
appear to hold any special meaning. The case-insensitive function should
be used as it implements a superset of functionality compared to the
case-sensitive version.
2017-06-26 21:05:42 +03:00
500f79a150 MXS-1296: Test that lc statements are parsed correctly
The transaction boundary parser - TrxBoundaryParser - must handle
upper and lowercase statements correctly.
2017-06-26 10:57:27 +03:00
09a445f1b7 Fix monitor credentials parameter names
The `monitoruser` and `monitorpw` parameters were mislabeled as `monuser`
and `monpw`. To allow backwards compatibility, the `monuser` and `monpw`
still work as aliases for the correct commands.
2017-06-05 13:20:16 +03:00
4050cd20d8 Merge branch '2.1-merge-2.0' into 2.1 2017-05-15 10:36:58 +03:00
ed653ac729 Merge branch '2.0' into 2.1-merge-2.0 2017-05-14 10:25:12 +03:00
70db289c60 MXS-1216: Fix DATETIME(n) value interpretation
The DATETIME(n) values generated by a MariaDB 10.0 server were not
interpreted correctly as the wrong algorithm was used to extract the
values.

DATETIME(0) values still do not work properly and they require further
debugging and changes to the code.
2017-05-12 16:50:41 +03:00
30bd869f1c MXS-1216: Fix crash on MariaDB 10.0 DATETIME(n)
When a MariaDB 10.0 DATETIME field with a custom length was defined, the
field offsets weren't calculated properly.

As there is no metadata for pre-10.1 DATETIME types with decimal
precision, the metadata (i.e. decimal count) needs to be gathered from the
CREATE TABLE statement. This information is then used to calculate the
correct field length when the value is decoded.

This change does not fix the incorrect interpretation of the old DATETIME
value. The converted values are still garbled due to the fact that the
value needs to be shifted out of the decimal format before it can be
properly converted.
2017-05-12 11:22:04 +03:00
6c583c43dd MXS-1263: Fix timeouts for partially established connections
When the connection timeout was checked for a connection, it assumed that
only valid and fully established sessions should be timed out.

Taking into account the fact that connections can be idle even before the
session is fully established, the check should be expanded to all
connections regardless of the session state.
2017-05-11 09:31:59 +03:00
8e2c7fd952 Merge branch '2.0' into 2.1 2017-05-10 09:12:42 +03:00
09349aaa22 Add missing string versions of MySQL commands
The STRPACKETTYPE macro was missing a number of the commands from the enum.

Added executed command byte value to readwritesplit info level log output.
2017-05-09 10:40:34 +03:00
ade2cef852 MXS-1244: added 'detect_stale_slave' in monitor params
'detect_stale_slave' added to monitor params
2017-04-24 10:34:13 +02:00
27e97a546d Remove superfluous logging
Just because of a debug build you do not want the transaction
parser to log.
2017-04-19 18:15:56 +03:00
a418387d0a MXS-1218 Poll statistics changed to 64bit to avoid looparound
Statistics calculation, printing and MaxInfo are modified.
n_fds remains 32bit.
2017-04-18 13:14:47 +03:00
a54d6fe816 Add connector plugindir to help output
The output now displays the connector directory.
2017-04-13 17:57:52 +03:00
9e8ddc842c Fix leaks in testconfig 2017-04-06 12:51:09 +03:00
15951423d8 Fix memory errors in test_poll and test_queuemanager
test_poll was calling poll_init() two times since it's already included in
init_test_env().

test_queuemanager was missing a bunch of frees. This doesn't fix it completely,
but removes most of the leaks and valgrind errors.
2017-04-05 17:37:21 +03:00
b1f66d21c8 Fix valgrind-errors in test_filter and test_modutil
Reduces valgrind clutter quite a bit.
2017-04-05 15:04:36 +03:00
2d987b25b2 Fix test_dcb
Set threadcount to one, don't check validity after freeing.
2017-04-05 10:49:43 +03:00
e0a98f6539 Fix calls of pcre2_substitute
If the output buffer given to pcre2_substitute is too small, an error
value is written to the last parameter (output length). That value
should not be used for calculations. This patch gives a copy as
parameter instead.

Coincidentally, this commit fixes the crashes of query classifier tests.

Also, increase buffer growth rate in utils.c.
2017-04-04 16:19:21 +03:00
dca086571b TestMaxScalePCRE2: Fix memory leaks
Not really leaks, but this reduces needless clutter in the valgrind
output.
2017-04-04 16:18:47 +03:00
8d2d6d8721 Join threads to prevent leaks 2017-04-03 14:20:54 +03:00
cbc1e864d9 Use RFC 3986 compliant addresses in log messages
When log messages are written with both address and port information, IPv6
addresses can cause confusion if the normal address:port formatting is
used. The RFC 3986 suggests that all IPv6 addresses are expressed as a
bracket enclosed address optionally followed by the port that is separate
from the address by a colon.

In practice, the "all interfaces" address and port number 3306 can be
written in IPv4 numbers-and-dots notation as 0.0.0.0:3306 and in IPv6
notation as [::]:3306. Using the latter format in log messages keeps the
output consistent with all types of addresses.

The details of the standard can be found at the following addresses:

     https://www.ietf.org/rfc/rfc3986.txt

     https://www.rfc-editor.org/std/std66.txt
2017-03-31 14:12:58 +03:00
8a86efc30e Fix gwbuf_clone
With this change, the test_clone() test in testbuffer.c no longer
causes a leak according to valgrind.
2017-03-30 22:16:51 +03:00
8284716e6a Add test for gwbuf_clone to testbuffer.c
- Under valgrind, this test reveals the leak of gebuf_clone.
2017-03-30 22:14:58 +03:00
29fa4a6088 Fix testbuffer.c
Free memory allocated by tests, so that it is meaningful to run under
valgrind in order to check for GWBUF leaks.
2017-03-30 22:02:34 +03:00
b4c119915b Fix gwbuf_rtrim
- If everything in the first buffer of a buffer chain is consumed,
  then the whole chain and not just the first buffer was freed.

NOTE: gwbuf_rtrim needs to be fixed so that it removes data from the
      tail of a chain and *not* from the end of the first buffer in
      a chain. That cannot ever be what is wanted.
2017-03-30 21:49:57 +03:00
a1d1413b24 Add atomic_add for 64-bit integers.
Now only GCC intrinsics are used.
2017-03-30 12:36:23 +03:00
b458b63756 Use IPv6 for created listeners
When listeners are created, use the default values of [::]:3306.
2017-03-29 17:14:39 +03:00
1901a3bc0a Bind to IPv6 addresses by default
The `::` address covers both IPv4 and IPv6 addresses allowing both IP
versions to be used by default.
2017-03-28 21:25:30 +03:00
d0a9571da0 Introduce new qc_parse() prototype
It is now possible to specify what information the caller is interested
in. With this the cost for collecting information during the query parsing
that nobody is interested in can be avoided.
2017-03-22 11:09:36 +02:00
3670edbc78 Spinlock cleanup
- Non-GCC intrinsics alternative implementation removed. Let's worry
  about the absence of the intrinsics once/if that becomes relevant.
- Spinlock release now performed using __sync_lock_release, as per
  svoj's advice.
- while-looping on the variable used as lock removed, so it no longer
  need to be volatile.
- Boolean function returns bool.
- Size of profiling counters increased.
- Risk for division-by-zero removed.
- Documentation moved from implementation to header.
2017-03-21 15:19:10 +02:00
4ca3c19ee3 Use [true|false] instead of [TRUE|FALSE] 2017-03-21 15:17:44 +02:00
0b5d164855 MXS-1167: Skip permission checks for internal services
If a server points to a local MaxScale listener, the permission checks for
that server are skipped. This allows permission checks to be used with a
mix of external servers and internal services.
2017-03-20 11:10:55 +02:00
1b418b517c Custom parsing for trx state is now the default
The possibility for turning on query_classifier parsing using
an environment variable is retained as a backdoor for sorting
out potential issues.
2017-03-17 12:30:20 +02:00
b52cc4e56b Take modutil_MySQL_bypass_whitespace into use 2017-03-17 11:54:00 +02:00
7469c5be52 Add functionality for bypassing MySQL whitespace/comments
This functionality is needed both in the query classifier, where
it was first created, and in the cache.
2017-03-17 10:27:16 +02:00
67590d59ac Fix connector_plugindir usage with basedir
The connector_plugindir wasn't set correctly when basedir was used.
2017-03-15 17:37:25 +02:00
5e39268e37 Remove support for TrxBoundaryMatcher
For the general case, regex matching simply will not do. The
regex becomes so hairy so it turns write-only, i.e. unmaintainable.
Regex matching is also slower than a handwritten custom parser.
2017-03-15 10:39:26 +02:00
1c8205e005 Add missing flag handling 2017-03-15 10:25:02 +02:00