1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-09-13 21:02:01 +03:00

351 Commits

Author SHA1 Message Date
Vladislav Vaintroub
c80f221f1c CONC-783 fixup - make sure that proxy header is not sent twice
in case of TLS connection.
2025-08-04 16:53:54 +02:00
Vladislav Vaintroub
c71865eca4 CONC-783 Fix potential loss of "Proxy header not accepted from host" error
Send the proxy header and handshake response in a single write.

If the client uses two separate send() calls, the server's error message
"Proxy header not accepted from host" may be lost. This occurs because
the server sends a TCP RST (reset) instead of a FIN if it closes the socket
while the client is still sending data.

As a result, the client may receive ECONNRESET or EPIPE, without seeing
the actual error from the server.
2025-08-04 15:17:11 +02:00
Vasilii Lakhin
40be423f08 Fix miscellaneous typos 2025-07-13 18:42:30 +03:00
Daniel Black
6fde019bfc caching_sha2_pw: free filebuffer and cleanup on Public key import failure 2025-05-29 15:42:34 +10:00
Georg Richter
4c9bc2b0f6 Merge branch '3.1' into 3.3 2025-02-27 07:52:35 +01:00
Georg Richter
aa240cd181 CONC-760: valid named pipe connection is closed
Fixed different behavior of pvio_is_alive (which was first used
with fix of CONC-589). Both for sockets and named pipe the function
now returns true if the connection is alive, otherwise false.
2025-02-27 07:48:58 +01:00
Georg Richter
e633858c9e Merge pull request #261 from markus456/3.3-zstd-compression-level
Add configurable zstd compression level
2024-12-09 22:22:08 +01:00
Georg Richter
136d295d02 Merge branch '3.1' into 3.3 2024-12-09 19:32:13 +01:00
Georg Richter
554893c269 CONC-711: Ubsan and ASAN fixes
- fixed write functions in my_auth.c
- fixed misalignment error when obtaining data via
  option MARIADB_OPT_USERDATA (mysql_get_optionv).
2024-12-09 19:28:10 +01:00
Markus Mäkelä
a2213b89d4 Add MYSQL_OPT_ZSTD_COMPRESSION_LEVEL
The compression level was always hard-coded to 3.
2024-11-07 06:51:57 +02:00
Markus Mäkelä
721103eba1 Fix zstd compression level bytes
The MySQL protocol documentation as well as the comments in code state
that the compression level is stored in one byte. The code, however,
used four bytes.
2024-11-07 06:49:41 +02:00
Sergei Golubchik
61ef765c43 change plugin TYPE in the REGISTER_PLUGIN to something useful
it's currently unused
2024-10-17 10:00:31 +02:00
Georg Richter
f705f346c7 Merge branch '3.1' into 3.3 2024-09-20 08:35:24 +02:00
Sergei Golubchik
c4153aa833 CONC-730 Undefined behavior in the reference Ed25519 implementation
Apply the fix from MXS-4686 and MDEV-31379

Seems to originate from https://github.com/hyperledger/iroha-ed25519/pull/22
2024-09-18 17:20:58 +10:00
Vladislav Vaintroub
998a8da4b0 MDEV-33513 On Windows, build auth_gssapi_client statically and dynamically.
With normal client, statically linked plugin with be used
The DLL is for the obscure in-server client, which we never got rid off.

That client is used with mariabackup, replication, and some storage engines,
e.g connect and federated.
2024-07-28 09:38:52 +02:00
Georg Richter
4d46ae76bc Merge branch '3.1' into 3.3 2024-05-08 11:43:18 +02:00
Sam James
51b2a621b3 Fix -Wcalloc-transposed-args
Fixes warnings like:
```
unittest/libmariadb/bulk1.c: In function ‘bulk1’:
unittest/libmariadb/bulk1.c:77:43: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
   77 |   lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE);
      |                                           ^~~~
unittest/libmariadb/bulk1.c:77:43: note: earlier argument should specify number of elements, later size of each element
unittest/libmariadb/bulk1.c:78:39: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argu
ment and not in the later argument [-Werror=calloc-transposed-args]
   78 |   vals= (unsigned int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
      |                                       ^~~
```

The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```

So, just swap the number of members and size arguments to match the
prototype, as we're initialising N struct of size Y. GCC then sees we're not
doing anything wrong.

Signed-off-by: Sam James <sam@gentoo.org>
2024-04-29 14:16:15 +02:00
Mosè Giordano
89d11c8b05 Fix sys/poll.h -> poll.h
See https://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.h.html, or the other files in this project referencing `poll.h`:
```console
% grep -r 'poll.h'                                                    
libmariadb/ma_net.c:#include <poll.h>
libmariadb/mariadb_lib.c:#include <poll.h>
plugins/pvio/pvio_socket.c:#include <sys/poll.h>
unittest/libmariadb/async.c:#include <poll.h>
```
2024-04-29 13:43:40 +02:00
Sergei Golubchik
f6e99af056 Revert "self-signed certificate verification", it's 3.4 feature
This reverts 395641549ac7..536d9e2b9e5b, in particular:

8dffd56936 MDEV-31857 enable MYSQL_OPT_SSL_VERIFY_SERVER_CERT by default
a99570c118 MDEV-31855 SSL cert validation protocol extension
9aa15e72a7 TLS fingerprint

and related commits
2024-02-19 11:16:26 +01:00
Sergei Golubchik
8dffd56936 MDEV-31857 enable MYSQL_OPT_SSL_VERIFY_SERVER_CERT by default
because the default value of every option is 0
(option and option.extension are bzero-ed to reset),
tls_verify_server_cert was renamed to tls_allow_invalid_server_cert
with the default value of 0, "do not allow".

API didn't change, it's still MYSQL_OPT_SSL_VERIFY_SERVER_CERT
2024-02-04 22:17:25 +01:00
Sergei Golubchik
fcef411ecb MDEV-31855 hash_password_bin for native_password and ed25519 2024-02-04 22:17:25 +01:00
Sergei Golubchik
79a746f290 unix socket and named pipes are secure
as in --require-secure-transport
2024-02-04 22:17:25 +01:00
Sergei Golubchik
a99570c118 MDEV-31855 SSL cert validation protocol extension
* extend the client auth plugin API with a new callback
* relax the plugin version check to allow load a plugin with the
  same major version, even if the minor versions differ
* implement the protocol extension:
  - don't abort at once if the certificate is self signed and
    no CA was explicitly specified
  - allow it if it passes fingerprint check
  - allow it if plugin has hash_password_bin callback, password was
    non-empty and the control hash matches server's
2024-02-04 22:17:25 +01:00
Vladislav Vaintroub
75ab6fb174 Allow named pipe connection handle to be used with IO completion port
Client programs can use pipe handle via mysql_get_socket().
They also might want to use IO completion ports with this handle.

Prevent IOCP notifications to be sent to completion port, for internal
read and write with timeout.
2023-11-19 16:46:36 +01:00
Georg Richter
4f5950b4b6 Merge branch '3.1' into 3.3 2023-10-21 19:46:00 +02:00
Georg Richter
8320f0d54d Fix error on 32-bit systems
Problem was introduced with fix for CONC-668.
2023-10-21 19:43:42 +02:00
Georg Richter
26b2eddbf4 Merge branch '3.1' into 3.3 2023-10-20 06:53:07 +02:00
Georg Richter
35cd69beb4 Fix for CONC-672:
To avoid a false positive GCC warning about possible string
truncation strncpy was replaced by memcpy.
2023-10-20 06:44:38 +02:00
Georg Richter
ab38a07b03 Fix for CONC-670:
Initialize time struct in pvio_socket_set_timeout.
2023-10-11 10:43:25 +02:00
Vladislav Vaintroub
463a50e973 Merge remote-tracking branch 'origin/3.1' into 3.3
# Conflicts:
#	include/ma_crypt.h
#	libmariadb/mariadb_lib.c
2023-09-21 23:45:35 +02:00
Vladislav Vaintroub
1b3cf6b441 CONC-669 Cache bcrypt algorithm providers in win_crypt.c
CryptOpenAlgorithmProvider() documentation states:
"We recommend that you cache any algorithm provider handles that you will
use more than once, rather than opening and closing the algorithm providers
over and over."

This patch implements algorithm handle caching,
and also simplifies how hashes are handled in win_crypt.c

- MA_HASH_CTX* is now just BCrypt hash handle.
- We no longer allocate or free memory any memory outselves.

There are small change in the ma_hash API:
ma_hash_new() lost the second parameter, only used on Windows previously
2023-09-21 18:06:01 +02:00
Georg Richter
4e3905c20a Fix for bcrypt hash functions:
Using a global crypt provider is not thread safe, so we need to load
provider via BCryptOpenProvider in ma_hash_new().
2023-08-23 16:18:50 +02:00
Georg Richter
3a255ee3ea Merge branch '3.1' into 3.3 2023-07-24 11:07:05 +02:00
Georg Richter
45feebb99d Remove server certification verification
Since the server certification option is used by client
only, there is no need to have this flag in server and or
client capabilities. The server itself validates client
certificate depending on the user definition.
2023-07-13 09:30:33 +02:00
Georg Richter
c2b322d2ca CONC-644: Build named pipe plugin as static plugin
Instead of building named pipe plugin as a dynamic
(external) plugin it can be used now as a static
(compiled in) plugin.
2023-05-02 18:30:31 +02:00
Georg Richter
aa614a8beb Merge branch '3.1' into 3.3 2023-04-05 09:28:40 +02:00
Georg Richter
5a94570b39 Fix for CONC-635: Disable TLS/SSL for named pipe/shared mem
Since the server doesn't support secure connections for
shared memory and named pipe connections but indicates
this capability by setting the CLIENT_SSL flag, we unset
this flag in case the connection uses shared memory
or named pipe.
2023-04-05 09:01:25 +02:00
Marko Mäkelä
93e9d091f7 Merge 3.1 into 3.3 2023-03-06 12:03:41 +02:00
Sergei Golubchik
4e2408c1cc CONC-637 Build fails when specifying -DPLUGIN_AUTH_GSSAPI_CLIENT=OFF 2023-02-28 19:58:50 +01:00
Georg Richter
516dd92b9d Merge pull request #210 from heirecka/3.3
Use find_package(GSSAPI) instead including the module
2023-02-21 06:44:34 +01:00
Georg Richter
bfd7110497 Revert "Merge pull request #210 from heirecka/3.3"
This reverts commit 62c546c623, reversing
changes made to 29a8156193.

This PR needs to be reverted since it throws a warning and doesn't build
the Kerberos/GSSAPI plugin at all.

CMake Warning:
By not providing "FindGSSAPI.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "GSSAPI", but
CMake did not find one.
2023-02-20 16:17:42 +01:00
Georg Richter
62c546c623 Merge pull request #210 from heirecka/3.3
Use find_package(GSSAPI) instead including the module
2023-02-18 09:08:15 +01:00
Georg Richter
14df82cdf3 Fix for CONC-634:
Don't switch to compressed protocol if it's not supported by server.
2023-02-11 14:45:44 +01:00
Heiko Becker
31f78bb289 Use find_package(GSSAPI) instead including the module
When including it, CMAKE_DISABLE_FIND_PACKAGE doesn't have the desired
effect. This can cause a CMake error when building mariadb:

"CMake Error at libmariadb/plugins/auth/CMakeLists.txt:123 (SET_TARGET_PROPERTIES):
  SET_TARGET_PROPERTIES Can not find target to add properties to:
  auth_gssapi_client"
2022-11-25 15:19:41 +01:00
Georg Richter
d9af4fcbc6 Merge branch '3.1' into 3.3 2022-11-07 09:09:29 +01:00
Georg Richter
44383e3df4 Fix for MDEV-29925
Since CHECK_COMPILER_FLAG doesn't work for linker flags,
we need to check the options with CHECK_LINKER_FLAG
(which is available since CMake 3.18)
2022-11-07 08:35:59 +01:00
Vladislav Vaintroub
6d489dd7ed MDEV-26715 Windows/installer - gssapi support
link client plugin statically, to avoid "plugin not found"
2022-11-01 13:52:21 +01:00
Sergei Golubchik
9ca66a7038 don't require libraries that aren't needed
krb5-config (used by FindGSSAPI) returns `-lkrb5 -lk5crypto -lcom_err`
but only libkrb5 is actually used by the plugin. The other two result
in unneeded dependencies unless they're tagged optional when linked
with --as-needed.

Some distributions use --as-needed automatically, which causes our
builds to differ from srpm builds, introducing failures in buildbot.
2022-09-20 19:13:57 +02:00
Sergei Golubchik
380ee32375 fix for old cmake versions 2022-09-20 10:12:38 +02:00
Sergei Golubchik
2e10c961eb don't require libraries that aren't needed
krb5-config (used by FindGSSAPI) returns `-lkrb5 -lk5crypto -lcom_err`
but only libkrb5 is actually used by the plugin. The other two result
in unneeded dependencies unless they're tagged optional when linked
with --as-needed.

Some distributions use --as-needed automatically, which causes our
builds to differ from srpm builds, introducing failures in buildbot.
2022-09-13 20:33:47 +02:00