1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

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).
This commit is contained in:
Georg Richter
2024-12-09 19:28:10 +01:00
parent 98ae464bf9
commit 554893c269
2 changed files with 6 additions and 6 deletions

View File

@@ -3488,7 +3488,7 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
(uint)strlen((char *)key)))) (uint)strlen((char *)key))))
{ {
p+= strlen(key) + 1; p+= strlen(key) + 1;
*((void **)data)= *((void **)p); memcpy(data, p, sizeof(void *));
break; break;
} }
if (data) if (data)

View File

@@ -6,7 +6,7 @@
#include <mysql/client_plugin.h> #include <mysql/client_plugin.h>
typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t; typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t;
static int client_mpvio_write_packet(struct st_plugin_vio*, const uchar*, size_t); static int client_mpvio_write_packet(struct st_plugin_vio*, const uchar*, int);
static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
static int dummy_fallback_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql __attribute__((unused))); static int dummy_fallback_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql __attribute__((unused)));
extern void read_user_name(char *name); extern void read_user_name(char *name);
@@ -16,7 +16,7 @@ extern unsigned char *mysql_net_store_length(unsigned char *packet, ulonglong le
typedef struct { typedef struct {
int (*read_packet)(struct st_plugin_vio *vio, uchar **buf); int (*read_packet)(struct st_plugin_vio *vio, uchar **buf);
int (*write_packet)(struct st_plugin_vio *vio, const uchar *pkt, size_t pkt_len); int (*write_packet)(struct st_plugin_vio *vio, const uchar *pkt, int pkt_len);
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info); void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
/* -= end of MYSQL_PLUGIN_VIO =- */ /* -= end of MYSQL_PLUGIN_VIO =- */
MYSQL *mysql; MYSQL *mysql;
@@ -465,7 +465,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf)
*/ */
static int client_mpvio_write_packet(struct st_plugin_vio *mpv, static int client_mpvio_write_packet(struct st_plugin_vio *mpv,
const uchar *pkt, size_t pkt_len) const uchar *pkt, int pkt_len)
{ {
int res; int res;
MCPVIO_EXT *mpvio= (MCPVIO_EXT*)mpv; MCPVIO_EXT *mpvio= (MCPVIO_EXT*)mpv;
@@ -473,9 +473,9 @@ static int client_mpvio_write_packet(struct st_plugin_vio *mpv,
if (mpvio->packets_written == 0) if (mpvio->packets_written == 0)
{ {
if (mpvio->mysql_change_user) if (mpvio->mysql_change_user)
res= send_change_user_packet(mpvio, pkt, (int)pkt_len); res= send_change_user_packet(mpvio, pkt, pkt_len);
else else
res= send_client_reply_packet(mpvio, pkt, (int)pkt_len); res= send_client_reply_packet(mpvio, pkt, pkt_len);
} }
else else
{ {