Skip to content

Commit

Permalink
rlm_sql_mysql: if we have mysql/mysql.h then include mysql/mysql.h, n…
Browse files Browse the repository at this point in the history
…ot mysql.h!
  • Loading branch information
arr2036 committed Aug 17, 2023
1 parent 402e15d commit 3dba118
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RCSID("$Id$")
#ifdef HAVE_MYSQL_MYSQL_H
# include <mysql/errmsg.h>
DIAG_OFF(strict-prototypes) /* Seen with homebrew mysql client 5.7.13 */
# include <mysql.h>
# include <mysql/mysql.h>
DIAG_ON(strict-prototypes)
# include <mysql/mysqld_error.h>
#elif defined(HAVE_MYSQL_H)
Expand Down Expand Up @@ -420,7 +420,7 @@ static sql_rcode_t sql_check_error(MYSQL *server, int client_errno)

static sql_rcode_t sql_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config, char const *query)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
sql_rcode_t rcode;
char const *info;

Expand All @@ -437,7 +437,7 @@ static sql_rcode_t sql_query(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t c

static sql_rcode_t sql_store_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
sql_rcode_t rcode;
int ret;

Expand All @@ -460,7 +460,7 @@ static sql_rcode_t sql_store_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_con

static int sql_num_fields(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
int num = 0;

#if MYSQL_VERSION_ID >= 32224
Expand Down Expand Up @@ -503,7 +503,7 @@ static sql_rcode_t sql_select_query(rlm_sql_handle_t *handle, rlm_sql_config_t c

static int sql_num_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

if (conn->result) return mysql_num_rows(conn->result);

Expand All @@ -512,7 +512,7 @@ static int sql_num_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const

static sql_rcode_t sql_fields(char const **out[], rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

unsigned int fields, i;
MYSQL_FIELD *field_info;
Expand Down Expand Up @@ -543,7 +543,7 @@ static sql_rcode_t sql_fields(char const **out[], rlm_sql_handle_t *handle, rlm_

static sql_rcode_t sql_fetch_row(rlm_sql_row_t *out, rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
sql_rcode_t rcode;
MYSQL_ROW row;
int ret;
Expand Down Expand Up @@ -595,7 +595,7 @@ static sql_rcode_t sql_fetch_row(rlm_sql_row_t *out, rlm_sql_handle_t *handle, r

static sql_rcode_t sql_free_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

if (conn->result) {
mysql_free_result(conn->result);
Expand Down Expand Up @@ -626,7 +626,7 @@ static sql_rcode_t sql_free_result(rlm_sql_handle_t *handle, UNUSED rlm_sql_conf
static size_t sql_warnings(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen,
rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

MYSQL_RES *result;
MYSQL_ROW row;
Expand Down Expand Up @@ -692,7 +692,7 @@ static size_t sql_error(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen,
rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
{
rlm_sql_mysql_t *inst = talloc_get_type_abort(handle->inst->driver_submodule->dl_inst->data, rlm_sql_mysql_t);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
char const *error;
size_t i = 0;

Expand Down Expand Up @@ -760,7 +760,7 @@ static size_t sql_error(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t outlen,
static sql_rcode_t sql_finish_query(rlm_sql_handle_t *handle, rlm_sql_config_t const *config)
{
#if (MYSQL_VERSION_ID >= 40100)
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);
int ret;
MYSQL_RES *result;

Expand Down Expand Up @@ -805,7 +805,7 @@ static sql_rcode_t sql_finish_query(rlm_sql_handle_t *handle, rlm_sql_config_t c

static int sql_affected_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t const *config)
{
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

return mysql_affected_rows(conn->sock);
}
Expand All @@ -814,7 +814,7 @@ static size_t sql_escape_func(UNUSED request_t *request, char *out, size_t outle
{
size_t inlen;
rlm_sql_handle_t *handle = talloc_get_type_abort(arg, rlm_sql_handle_t);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(rlm_sql_mysql_conn_t, handle->conn);
rlm_sql_mysql_conn_t *conn = talloc_get_type_abort(handle->conn,rlm_sql_mysql_conn_t);

/* Check for potential buffer overflow */
inlen = strlen(in);
Expand Down

0 comments on commit 3dba118

Please sign in to comment.