With proxy protocol thd_set_peer_addr() runs twice (proxy host, then the
real client from the proxy header). Connect errors are accounted against
the real client, but check_connection() incorrectly uses condition on the
proxy host's count, rather than real client's address.
Fix: reset both the proxy host, and real client's connect errors on
successful connection.
Added tests for incomplete handshake, and reset behavior,
under proxy protocol, for both real client errors, and proxy host errors.
The MEMORY_LEAK_C reports in this file are false positives. Real leaks are
reported by ASAN, which we run regularly. Suppress the leak checker for the
file with the documented @infer-ignore-every directive.
Infer flagged several test/unittest sites that dereference the result of
an allocation (or an allocating helper) without checking it for NULL:
- tests/async_queries.c: fatal() calls exit() but was not marked
noreturn, so Infer assumed add_query() continued past the
"if (!e || !q2) fatal(...)" guard. Mark fatal() ATTRIBUTE_NORETURN.
- tests/mysql_client_test.c: add the usual check_stmt() after
mysql_stmt_init() in test_bug16143, test_bug16144 and test_bug38486.
- unittest/json_lib/json_normalize-t.c: check init_dynamic_string().
- unittest/mysys/bitmap-t.c: check my_bitmap_init().
- unittest/mysys/ma_dyncol-t.c: check the val/upd/res malloc()s.
- unittest/mysys/thr_template.c: replace assert(threads) (compiled out
under NDEBUG) with an unconditional check.
- unittest/sql/mf_iocache-t.cc: check the buf/buf_i/buf_o malloc()s.
Test-only changes; on allocation failure the tests now abort cleanly
via BAIL_OUT() instead of dereferencing NULL.
When proxy protocol is used and --skip-name-resolve is not set,
thd_set_peer_addr() is called twice per connection: once for the real TCP peer (in check_connection),
and again for the proxied address (in handle_proxy_header).
Each call invokes ip_to_hostname(), which allocates a hostname string
(unless loopback connection is used) and stores it as
thd->main_security_ctx.host. That code missed to free previously
allocated hostname, which results into memory leak.
This is now fixed. Also added debug-only test to mysql_client_test, which
fakes DNS and IP resolution the same way some perfschema tests do, to
emulate remote TCP connection in MTR.
x32 defines __x86_64__ but uses the ILP32 ABI, so the LP64
sizeof(MYSQL) == 1272 compile-time assert is selected incorrectly
and breaks the build.
Guard the x86_64 check with !defined(__ILP32__) so the LP64 size assert
only applies to real amd64 LP64 builds, while leaving the existing
Windows amd64 and i386 checks unchanged.
Make sure null terminator byte that is added at the end of header
is within boundaries of 'hdr' array.
This patch is based on https://github.com/MariaDB/server/pull/4881
by Uwez Khan
Remove the unscoped #pragma GCC diagnostic ignored
"-Wdeprecated-declarations" from include/violite.h and replace all
sprintf/vsprintf calls with snprintf/vsnprintf across the codebase.
Where possible, pass actual buffer sizes as function parameters
instead of using hardcoded constants or recomputing strlen().
Notable API changes:
- get_date(): added to_len parameter for buffer size
- nice_time(), end_timer() in client/mysql.cc: added buff_size
- generate_new_name(): added name_size parameter
- calc_md5(): added buffer_size parameter (fixes off-by-one)
- MD5_HASH_TO_STRING macro: added _size parameter
- Added MYSQL_UDF_MAX_RESULT_LENGTH constant in mysql_com.h
Also fixed a pre-existing bug in sql/rpl_mi.cc where the ellipsis
"..." was written to the wrong buffer (dbuff instead of buff).
Vendored code is excluded: extra/readline, extra/wolfssl,
wsrep-lib, libmariadb, storage/mroonga/vendor, zlib.
Problem:
A stored procedure querying a view with `CONCAT`/`GROUP_CONCAT` could
crash due to a NULL pointer dereference during query optimization.
During condition pushdown, `Item_direct_ref_to_item::deep_copy`
creates a clone where the clone's `ref` pointer incorrectly remains
pointing to the original object's `m_item`, rather than its own.
Because the clone is tethered to the original object, subsequent
transformations happen on the original item instead of the clone.
Calling `fix_fields` on malformed `Item_direct_ref_to_item` clone
resolves to `Item_field::fix_fields` instead of `Item_ref::fix_fields`
leaving the member `Item_ref::ref` uninitialized (NULL). When this is
dereferenced in `Item_ref::const_item`, server crashes.
Fix:
The `Item_direct_ref_to_item::set_item` method is made to update the
item and reference, making the clone complete. This results in correct
`fix_fields` resolution, making `Item_ref::ref` safe to access.
Other things:
- Extended mysqltest to write GTID's for master and slave if
sync_slave_with_master fails.
Reviewer: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
all params are initialized to use Type_handler_null.
NULL params do not have a value to read from the packet buffer,
so their Item_param_set_param_func() should do nothing.
Type_handler_null inherits from Type_handler_string_result,
that is, Type_handler_null *must* override parent's
Item_param_set_param_func().
Replace broken URLs of boost-program-options and openssl1.1
with archives.fedoraproject.org for stable RPM access.
Update upgrade paths by removing 10.3/10.4 and adding 11.8 version.
All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
This commit introduces:
- the infrastructure for optimizer hints;
- hints for join buffering: BNL(), NO_BNL(), BKA(), NO_BKA();
- NO_ICP() hint for disabling index condition pushdown;
- MRR(), MO_MRR() hint for multi-range reads control;
- NO_RANGE_OPTIMIZATION() for disabling range optimization;
- QB_NAME() for assigning names for query blocks.
Get rid of need of matherialization for usual INSERT (cache results in
Item_cache* if needed)
- subqueries in VALUE do not see new records in the table we are
inserting to
- subqueries in RETIRNING prohibited to use the table we are inserting to
- fix several Windows-specific "variable set but not used",
or "variable unused" warnings.
- correctly initialize std::atomic_flag (ATOMIC_FLAG_INIT)
- fix Ninja build for spider on Windows
- adjust check for sizeof(MYSQL) for Windows compilers