1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-09-11 08:30:59 +03:00
Commit Graph

85 Commits

Author SHA1 Message Date
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
4d46ae76bc Merge branch '3.1' into 3.3 2024-05-08 11:43:18 +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
Georg Richter
26b2eddbf4 Merge branch '3.1' into 3.3 2023-10-20 06:53:07 +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
Georg Richter
6ab1397119 Fix for CONC-612:
When connecting via socket (non unix-socket) the connection can't
be established if the wait function (usleep) returns an error and
modifies errno. This is the case on MacOSX, where usleep() returns
-1 and sets errno to ETIMED_OUT. This patch saves errno from connect()
call and restores it after usleep.

This bug was introduced with PR204 (commit dfe3563192)
2022-09-02 10:05:20 +02:00
Georg Richter
4f715e8fb1 Fix for CONC-612:
When connecting via socket (non unix-socket) the connection can't
be established if the wait function (usleep) returns an error and
modifies errno. This is the case on MacOSX, where usleep() returns
-1 and sets errno to ETIMED_OUT. This patch saves errno from connect()
call and restores it after usleep.

This bug was introduced with PR204 (commit dfe3563192)
2022-09-02 09:50:58 +02:00
Georg Richter
274f2face2 Merge pull request #199 from hyung-hwan/3.3
enhanced mysql_close_slow_part() and other related parts to prevent memory leaks in the non-blocking mode
2022-07-25 09:22:04 +02:00
Georg Richter
dfe3563192 Fix for CONC-607 (Infinite loop in pvio_socket_internal_connect)
A retry interval is added in the loop to avoid exhausting
the CPU resource. Also the elapsed time in the loop will be
checked and break if it passed the timeout threshold.

Kudos to Hugo Wen who reported this issue and provided the fix!
2022-07-24 17:36:49 +02:00
hyunghwan.chung
c0fea17e2a enhanced mysql_close() and other related parts to prevent memory leaks when terminating an initiated but unestablished connection 2022-06-21 17:49:45 +09:00
Georg Richter
da5bc50ffa Merge branch 'syntax-error' of git://github.com/omega-software/mariadb-connector-c into omega-software-syntax-error 2022-03-02 17:17:11 +01:00
Georg Richter
49be7b28b6 Merge pull request #124 from EGuesnet/AIX
[CONC-430] Compilation on AIX
2020-08-13 14:38:48 +02:00
Oleksandr Byelkin
895dcb61e3 C preprocessor defines fix 2020-06-04 16:49:21 +02:00
Georg Richter
1218ffac1a Fix for CONC-452 and CONC-453:
Various coverity scan fixes, including CONC-452 and CONC-453.
Special thanks to Lukas Javorsky for fixing numerous covscan
issues (This patch includes part of his pull request #126).

Coverity scan build was using the following cmake parameters:
-WITH_EXTERNAL_ZLIB=ON -DWITH_UNIT_TESTS=OFF.

CWE-416 (use after free) in dtoa.c (from netlib) is still open.
2020-02-14 09:52:21 +01:00
Etienne Guesnet
448dfbc7f3 AIX macro 2020-01-09 17:14:56 +01:00
Noel Kuntze
fe117c16a3 Do not overwrite final byte of array to make sure it's always zero 2019-05-29 20:37:29 +02:00
Georg Richter
abce2a3ab3 CONC-377: Add IO Callback
Applied part of the patch from https://github.com/MariaDB/mariadb-connector-c/pull/71
The part for named pipes doesn't work, since wait_io was reworked by vvaintroub.
2018-12-01 16:46:46 +01:00
Georg Richter
501b90bb74 Fix for CONC-364: Not all sockets created in pvio_socket_connect function are closed 2018-10-23 11:52:20 +02:00
Georg Richter
5cb4d8d77c Fixed typo which broke windows build 2018-07-27 07:46:05 +02:00
Daniel Black
b19f6a475b CONC-329: change pvio_*_blocking to return int to accomidate SOCKET_ERROR(-1)
POWER and other architectures that define char(as my_bool) to be unsigned (as the C
standard leaves this undefined). This resulted in error branches being
unreachabe as indicated by the below compile warnings.

plugins/pvio/pvio_socket.c:763:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
      false [-Wtautological-constant-out-of-range-compare]
    if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:875:46: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
      false [-Wtautological-constant-out-of-range-compare]
        if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~
plugins/pvio/pvio_socket.c:907:42: warning: comparison of constant -1 with expression of type 'my_bool' (aka 'char') is always
      false [-Wtautological-constant-out-of-range-compare]
    if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)

ma_hext2int: signed char - prevent compiler errors when char is unsigned.

libmariadb/ma_tls.c:169:31: warning: comparison of constant -1 with expression of type 'char' is always false
      [-Wtautological-constant-out-of-range-compare]
    if ((d1 = ma_hex2int(*p)) == - 1 ||
        ~~~~~~~~~~~~~~~~~~~~~ ^  ~~~
libmariadb/ma_tls.c:170:35: warning: comparison of constant -1 with expression of type 'char' is always false
      [-Wtautological-constant-out-of-range-compare]
        (d2 = ma_hex2int(*(p+1))) == -1 ||
        ~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~

To fix this all the pvio_*_blocking functions have been changed to use
int as a return value.

Other my_bool/char differences fixed:

mariadb_dyncol_val_str: fix prototype to use char - like implemented function.

unittest: bind.is_null is my_bool* so we use a my_bool.
2018-07-19 08:12:33 +10:00
Georg Richter
c95f86e882 More coverity fixes 2018-07-13 12:30:13 +02:00
Georg Richter
b0f2e4e72f Coverity fixes and travis integration 2018-07-06 09:28:24 +02:00
Daniel Black
fdbc31aa8e MDEV-15655: abstract socket support - fix length(2)
Thanks to Sergey Vojtovich:

On OS X sockaddr_un is defined as:

struct sockaddr_un
{
  u_char sun_len;
  u_char sun_family;
  char  sun_path[104];
};

There is a comment in man 7 unix (on linux):

On Linux, the above offsetof() expression equates to the same value as sizeof(sa_family_t), but some other implementations include other fields before sun_path, so the offsetof() expression more portably describes the size of the address structure.

As such use the offsetof for Linux and use the previous sizeof(UNIXaddr)
for non-unix platforms as that's what worked before and they don't
support abstract sockets so there's no compatibility problem..

Based off: 569e3ad1ead6469fa9019a399dcef8d4f2fb71b4 (in server)
2018-05-15 09:56:43 +10:00
Georg Richter
fbca960c33 Fixed another logical-op warning if EAGAIN and EWOULDBLOCK have same values. 2018-04-24 17:20:07 +02:00
Georg Richter
443f7568ee Revert "Added -Wlogical-op warning flag and fixed two warnings"
This reverts commit 2198a01fed.
2018-04-24 17:17:20 +02:00
Georg Richter
2198a01fed Added -Wlogical-op warning flag and fixed two warnings 2018-04-24 17:04:59 +02:00
Daniel Black
6d929464e2 MDEV-15655: abstract socket support - limit length
Unlike UNIX filesystem sockets, abstract sockets need to be length
limited because nulls are insignificant in the name.

Limiting this doesn't have any effect on UNIX filesystem sockets.

Thanks to Sergey Vojtovich
2018-04-18 19:00:27 +10:00
Georg Richter
db1028f62d Merge pull request #43 from grooverdan/MDEV-15655-abstract-sockets
MDEV-15655: Add Linux abstract socket support
2018-04-17 11:31:45 +02:00
Georg Richter
128d152f19 CONC-322:
Correct handling of EAGAIN and EINPROGRESS in internal_connect (socket) for non windows platforms.
Kudos to Daniel Black for providing this patch.
2018-04-12 16:22:38 +02:00
Georg Richter
50d48e91fa Reworked plugin interface
Plugin configuration happens now in CMakeLists.txt files in corresponding plugin directories.

plugins.cmake now contains REGISTER_PLUGIN_FUNCTION which accepts the following parameters:
  - TARGET: the name of the plugin (dynamic plugins will be named ${TARGET}.so (or .dll)
  - SOURCES: source files
  - LIBRARIES: additional libraries for linking
  - INCLUDES: include directories
  - CONFIGURATIONS: possible plugin configurations: valid arguments are DYNAMIC, STATIC, OFF
  - DEFAULT: default configuration (see CONFIGURATIONS)
  - COMPILE_OPTIONS: compiler flags

The default plugin configuration can be specified via cmake parameter -DCLIENT_PLUGIN_${TARGET}=[DYNAMIC|STATIC|OFF]
2018-04-07 07:14:43 +02:00
Daniel Black
ab5977166d MDEV-15655: Add Linux abstract socket support
Consistent with the server implementation extend the
client connection via unix socket to use an abstract
socket where the start of the path is '@'.

When this occurs the remainder of the name is the
abstract socket socket name. This is consistent with the
approached used by systemd in socket activation.
2018-03-25 14:12:30 +11:00
Georg Richter
929614903e Travis and Appveyor integration:
- added travis support
  - fixed appveyor settings
  - fixed some warnings (gcc 4.8)
  - removed sleep commands
  - disabled failing tests when running against MySQL server,
    mostly related to stored procedures and binary protocol
  - reverted fix for MDEV_10361

Still open: TLS/SSL appveyor tests, since .msi installation on appveyor doesn't provide certificates.
2018-02-16 12:14:01 +01:00
Vladislav Vaintroub
67cc3438a8 Fix unit test.
Fix send() prototype
2018-02-14 19:35:31 +00:00
Vladislav Vaintroub
7698e3f95e more clang fixes 2018-02-12 16:47:43 +00:00
Vladislav Vaintroub
aed8005e2e Fix clang on Windows warnings
- STDCALL is ignored for variable argument functions.
- __attribute__ does work for Clang (also if that pretends to be MSVC)
- remove unused function
- simplify ma_getopt, fixes some strange compile error in clang (about
SSE intrinsics)

- fix some clang warnings
2018-02-09 19:10:50 +01:00
Paul Graham
22cf14c47e Fix syntax error 2017-11-12 18:48:51 +01:00
Georg Richter
9d1a7aeede Fix parentheses (MDEV-13956) 2017-09-30 14:15:56 +02:00
Georg Richter
5bf7813413 Fix parentheses (MDEV-13956) 2017-09-29 11:12:36 +02:00
Georg Richter
0f11352134 Fixed compiler warnings 2017-07-04 13:59:40 +02:00
Georg Richter
ea8a31e63a Fixed compiler warnings 2017-07-04 13:56:38 +02:00
Georg Richter
467a193b39 Windows fixes:
fix for timeout failures in buildbot
  fixed sha256 password plugin:
    instead of using mysql_ssl_cipher, we rely on client_flag & CLIENT_SSL
    to check if a secure connection is used.
2017-05-10 13:29:58 +02:00
Georg Richter
d2aec415d7 Minor fixes:
fixed compiler warnings in openssl.c and dialog.c
  fixed timeout setting (was wrong in a previous commit)
  disabled session tracking test
2017-05-09 16:40:09 +02:00
Georg Richter
44a740c348 Fix for CONC-247: merge 8b3695271c (error check for timeout on sockets= 2017-04-10 06:23:25 +02:00
Vladislav Vaintroub
50fb1b28c3 Fix calculation of fcntl flags in pvio_socket_blocking(). 2017-03-29 21:02:10 +00:00
Vladislav Vaintroub
ba22ae8c6d Fix schannel and other socket io bugs on Windows.
- Fix a breaking change where
SP_PROT_TLS1_2_CLIENT bit was set in Cred.grbitEnabledProtocols by default.

This makes any SSL connection to Windows server fai, because
all yassl-based servers, in all MariaDB versions would abort
a client that is trying to use TLS1.2
(This is covered MDEV-12190)

As a consequence, client on Windows would not connect to any
server on Windows. For compatibility reasons therefore, 1.2 should NOT
be used by clients by default, otherwise it will break applications
connectivity to both Oracle MySQL and MariaDB's yassl based servers.
This also holds after MDEV-12190 is fixed,  because older servers
will be used for a while.


- Cred.dwFlag was missing SCH_CRED_NO_DEFAULT_CREDS flag,
which resulted in a popup on the build servers, asking to insert
a smartcard during client SSL handshake.

Smaller bugs in schannel :
 cipher_name() was returning pointer to member of stack allocated struct

Socket IO fixes

- errno rather than WSAGetLastError() was tested on Windows in
  pvio_socket_write/pvio_socket_read.
  Fixed by using socker_errno and simplided function to avoid numerious #ifdef _WIN32

- simplified vio_set_blocking, it had a rather inefficient implementation
  setting the same flags with ioctlsocket/fcntl over and over again.
2017-03-29 16:33:16 +00:00
Georg Richter
6220d9c9ae Fix for Windows socket communication: Use send/recv instead of corresponding WSA* functions 2017-03-23 17:42:50 +01:00
Georg Richter
6655a8194e Remove unused include file
remove link to mariadbclient library
2017-01-21 19:36:16 +01:00
Georg Richter
413b8bcba2 Build fix for OpenSSL_1.1
Fixed connection error message on windows (deliver correct error code)
2016-12-13 12:39:32 +01:00
Georg Richter
967b2830d8 renamed ma_errmsg.h back to errmsg.h 2016-11-16 18:13:59 +01:00