diff options
Diffstat (limited to 'mod_log_sql_mysql.c')
-rw-r--r-- | mod_log_sql_mysql.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c index e64044e..f058110 100644 --- a/mod_log_sql_mysql.c +++ b/mod_log_sql_mysql.c | |||
@@ -55,7 +55,7 @@ static logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnectio | |||
55 | host, tcpport, database, user, socketfile); | 55 | host, tcpport, database, user, socketfile); |
56 | return LOGSQL_OPENDB_SUCCESS; | 56 | return LOGSQL_OPENDB_SUCCESS; |
57 | } else { | 57 | } else { |
58 | log_error(APLOG_MARK,APLOG_DEBUG,0, s,"mod_log_sql: database connection error: %s", | 58 | log_error(APLOG_MARK,APLOG_ERR,0, s,"mod_log_sql: database connection error: %s", |
59 | MYSQL_ERROR(dblink)); | 59 | MYSQL_ERROR(dblink)); |
60 | log_error(APLOG_MARK,APLOG_DEBUG, 0, s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'", | 60 | log_error(APLOG_MARK,APLOG_DEBUG, 0, s,"HOST: '%s' PORT: '%d' DB: '%s' USER: '%s' SOCKET: '%s'", |
61 | host, tcpport, database, user, socketfile); | 61 | host, tcpport, database, user, socketfile); |
@@ -85,23 +85,24 @@ static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, | |||
85 | /* Pre-allocate a new string that could hold twice the original, which would only | 85 | /* Pre-allocate a new string that could hold twice the original, which would only |
86 | * happen if the whole original string was 'dangerous' characters. | 86 | * happen if the whole original string was 'dangerous' characters. |
87 | */ | 87 | */ |
88 | to_str = (char *) apr_palloc(p, length * 2 + 1); | 88 | to_str = (char *) apr_palloc(p, length * 2 + 3); |
89 | if (!to_str) { | 89 | if (!to_str) { |
90 | return from_str; | 90 | return from_str; |
91 | } | 91 | } |
92 | 92 | strcpy(to_str, "'"); | |
93 | if (!db->connected) { | 93 | if (!db->connected) { |
94 | /* Well, I would have liked to use the current database charset. mysql is | 94 | /* Well, I would have liked to use the current database charset. mysql is |
95 | * unavailable, however, so I fall back to the slightly less respectful | 95 | * unavailable, however, so I fall back to the slightly less respectful |
96 | * mysql_escape_string() function that uses the default charset. | 96 | * mysql_escape_string() function that uses the default charset. |
97 | */ | 97 | */ |
98 | retval = mysql_escape_string(to_str, from_str, length); | 98 | retval = mysql_escape_string(to_str+1, from_str, length); |
99 | } else { | 99 | } else { |
100 | /* MySQL is available, so I'll go ahead and respect the current charset when | 100 | /* MySQL is available, so I'll go ahead and respect the current charset when |
101 | * I perform the escape. | 101 | * I perform the escape. |
102 | */ | 102 | */ |
103 | retval = mysql_real_escape_string((MYSQL *)db->handle, to_str, from_str, length); | 103 | retval = mysql_real_escape_string((MYSQL *)db->handle, to_str+1, from_str, length); |
104 | } | 104 | } |
105 | strcat(to_str,"'"); | ||
105 | 106 | ||
106 | if (retval) | 107 | if (retval) |
107 | return to_str; | 108 | return to_str; |
@@ -109,6 +110,7 @@ static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, | |||
109 | return from_str; | 110 | return from_str; |
110 | } | 111 | } |
111 | } | 112 | } |
113 | |||
112 | #if defined(WIN32) | 114 | #if defined(WIN32) |
113 | #define SIGNAL_GRAB | 115 | #define SIGNAL_GRAB |
114 | #define SIGNAL_RELEASE | 116 | #define SIGNAL_RELEASE |
@@ -243,7 +245,7 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection | |||
243 | return LOGSQL_TABLE_SUCCESS; | 245 | return LOGSQL_TABLE_SUCCESS; |
244 | } | 246 | } |
245 | 247 | ||
246 | static char *supported_drivers[] = {"mysql",NULL}; | 248 | static const char *supported_drivers[] = {"mysql",NULL}; |
247 | static logsql_dbdriver mysql_driver = { | 249 | static logsql_dbdriver mysql_driver = { |
248 | supported_drivers, | 250 | supported_drivers, |
249 | log_sql_mysql_connect, /* open DB connection */ | 251 | log_sql_mysql_connect, /* open DB connection */ |