diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-04 08:24:06 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-10-04 08:24:06 +0300 |
commit | 2c1067166d7e8a9541578220b408f1e553e23916 (patch) | |
tree | 2ba0932f92d88e01d51393de63dda842f6daf320 /plugin | |
parent | 2cf3e2ea2fca3d3613309de94d55c88dedb3831a (diff) | |
parent | 61b2618d3aae78950f1b8dbe8d4482573c77875d (diff) | |
download | mariadb-git-2c1067166d7e8a9541578220b408f1e553e23916.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/auth_ed25519/server_ed25519.c | 5 | ||||
-rw-r--r-- | plugin/auth_pipe/auth_pipe.c | 4 | ||||
-rw-r--r-- | plugin/feedback/feedback.cc | 2 | ||||
-rw-r--r-- | plugin/feedback/sender_thread.cc | 2 | ||||
-rw-r--r-- | plugin/feedback/utils.cc | 14 | ||||
-rw-r--r-- | plugin/file_key_management/parser.cc | 4 | ||||
-rw-r--r-- | plugin/file_key_management/parser.h | 3 | ||||
-rw-r--r-- | plugin/query_response_time/query_response_time.cc | 2 | ||||
-rw-r--r-- | plugin/server_audit/server_audit.c | 61 | ||||
-rw-r--r-- | plugin/userstat/index_stats.cc | 6 |
10 files changed, 50 insertions, 53 deletions
diff --git a/plugin/auth_ed25519/server_ed25519.c b/plugin/auth_ed25519/server_ed25519.c index 88760275b9b..e3f00409ae3 100644 --- a/plugin/auth_ed25519/server_ed25519.c +++ b/plugin/auth_ed25519/server_ed25519.c @@ -33,7 +33,6 @@ static int loaded= 0; static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) { - unsigned int i; int pkt_len; unsigned long nonce[CRYPTO_LONGS + NONCE_LONGS]; unsigned char *pkt, *reply= (unsigned char*)nonce; @@ -51,8 +50,8 @@ static int auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) info->password_used= PASSWORD_USED_YES; /* prepare random nonce */ - for (i=CRYPTO_LONGS; i < CRYPTO_LONGS + NONCE_LONGS; i++) - nonce[i]= thd_rnd(info->thd) * ~0UL; + if (my_random_bytes((unsigned char *)nonce, (int)sizeof(nonce))) + return CR_AUTH_USER_CREDENTIALS; /* send it */ if (vio->write_packet(vio, reply + CRYPTO_BYTES, NONCE_BYTES)) diff --git a/plugin/auth_pipe/auth_pipe.c b/plugin/auth_pipe/auth_pipe.c index 20c33c07e84..a803653b31a 100644 --- a/plugin/auth_pipe/auth_pipe.c +++ b/plugin/auth_pipe/auth_pipe.c @@ -36,7 +36,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) unsigned char *pkt; MYSQL_PLUGIN_VIO_INFO vio_info; char username[UNLEN + 1]; - size_t username_length; + DWORD username_length; int ret; /* no user name yet ? read the client handshake packet with the user name */ @@ -54,7 +54,7 @@ static int pipe_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) if (!ImpersonateNamedPipeClient(vio_info.handle)) return CR_ERROR; - username_length= sizeof(username) - 1; + username_length=UNLEN; ret= CR_ERROR; if (GetUserName(username, &username_length)) { diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc index 81a08c8bdf0..8ed6ef64b0c 100644 --- a/plugin/feedback/feedback.cc +++ b/plugin/feedback/feedback.cc @@ -112,7 +112,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter) Item_field *fld= new (thd->mem_root) Item_field(thd, &nrc, db, table, field); Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str, - filter->length, cs); + (uint) filter->length, cs); Item_string *escape= new (thd->mem_root) Item_string(thd, "\\", 1, cs); if (!fld || !pattern || !escape) diff --git a/plugin/feedback/sender_thread.cc b/plugin/feedback/sender_thread.cc index 4742d5f4920..bcd10f6713f 100644 --- a/plugin/feedback/sender_thread.cc +++ b/plugin/feedback/sender_thread.cc @@ -238,7 +238,7 @@ static void send_report(const char *when) Url *url= todo[i]; if (thd) // for nicer SHOW PROCESSLIST - thd->set_query(const_cast<char*>(url->url()), url->url_length()); + thd->set_query(const_cast<char*>(url->url()), (uint) url->url_length()); if (url->send(str.ptr(), str.length())) i++; diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index a43dad8d630..09abbb2de23 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -151,7 +151,7 @@ namespace feedback { */ #define INSERT2(NAME,LEN,VALUE) \ do { \ - table->field[0]->store(NAME, LEN, system_charset_info); \ + table->field[0]->store(NAME, (uint) LEN, system_charset_info); \ table->field[1]->store VALUE; \ if (schema_table_store_record(thd, table)) \ return 1; \ @@ -159,7 +159,7 @@ namespace feedback { #define INSERT1(NAME,VALUE) \ do { \ - table->field[0]->store(NAME, sizeof(NAME)-1, system_charset_info); \ + table->field[0]->store(NAME, (uint) sizeof(NAME)-1, system_charset_info); \ table->field[1]->store VALUE; \ if (schema_table_store_record(thd, table)) \ return 1; \ @@ -186,7 +186,7 @@ static my_bool show_plugins(THD *thd, plugin_ref plugin, void *arg) (plugin_decl(plugin)->version) & 0xff); INSERT2(name, name_len, - (version, version_len, system_charset_info)); + (version, (uint)version_len, system_charset_info)); name_len= my_snprintf(name, sizeof(name), "%s used", plugin_name(plugin)->str); @@ -358,10 +358,10 @@ int fill_linux_info(THD *thd, TABLE_LIST *tables) #ifdef HAVE_SYS_UTSNAME_H if (have_ubuf) { - INSERT1("Uname_sysname", (ubuf.sysname, strlen(ubuf.sysname), cs)); - INSERT1("Uname_release", (ubuf.release, strlen(ubuf.release), cs)); - INSERT1("Uname_version", (ubuf.version, strlen(ubuf.version), cs)); - INSERT1("Uname_machine", (ubuf.machine, strlen(ubuf.machine), cs)); + INSERT1("Uname_sysname", (ubuf.sysname, (uint) strlen(ubuf.sysname), cs)); + INSERT1("Uname_release", (ubuf.release, (uint) strlen(ubuf.release), cs)); + INSERT1("Uname_version", (ubuf.version, (uint) strlen(ubuf.version), cs)); + INSERT1("Uname_machine", (ubuf.machine, (uint) strlen(ubuf.machine), cs)); } #endif diff --git a/plugin/file_key_management/parser.cc b/plugin/file_key_management/parser.cc index 03f78422c47..13a9dfa0cb6 100644 --- a/plugin/file_key_management/parser.cc +++ b/plugin/file_key_management/parser.cc @@ -231,9 +231,9 @@ bool Parser::parse_file(std::map<uint,keyentry> *keys, const char *secret) return 0; } -void Parser::report_error(const char *reason, uint position) +void Parser::report_error(const char *reason, size_t position) { - my_printf_error(EE_READ, "%s at %s line %u, column %u", + my_printf_error(EE_READ, "%s at %s line %u, column %zu", ME_ERROR_LOG, reason, filename, line_number, position + 1); } diff --git a/plugin/file_key_management/parser.h b/plugin/file_key_management/parser.h index 627b7fd84a6..044be0f5b95 100644 --- a/plugin/file_key_management/parser.h +++ b/plugin/file_key_management/parser.h @@ -23,6 +23,7 @@ Created 09/15/2014 #include <my_crypt.h> #include <ctype.h> #include <map> +#include <stdlib.h> /* size_t */ struct keyentry { unsigned int id; @@ -43,7 +44,7 @@ class Parser unsigned char *key, unsigned char *iv); bool read_filekey(const char *filekey, char *secret); bool parse_file(std::map<unsigned int ,keyentry> *keys, const char *secret); - void report_error(const char *reason, unsigned int position); + void report_error(const char *reason, size_t position); int parse_line(char **line_ptr, keyentry *key); char* read_and_decrypt_file(const char *secret); diff --git a/plugin/query_response_time/query_response_time.cc b/plugin/query_response_time/query_response_time.cc index 10b9391d9da..5d6119d20ef 100644 --- a/plugin/query_response_time/query_response_time.cc +++ b/plugin/query_response_time/query_response_time.cc @@ -221,7 +221,7 @@ public: print_time(total, sizeof(total), TOTAL_STRING_FORMAT, this->total(i)); } fields[0]->store(time,strlen(time),system_charset_info); - fields[1]->store(this->count(i)); + fields[1]->store((longlong)this->count(i),true); fields[2]->store(total,strlen(total),system_charset_info); if (schema_table_store_record(thd, table)) { diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index 2f6c8a8afda..1035065eec0 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -20,6 +20,7 @@ #define _my_thread_var loc_thread_var #include <my_config.h> +#include <assert.h> #ifndef _WIN32 #include <syslog.h> @@ -138,7 +139,7 @@ static size_t loc_write(File Filedes, const uchar *Buffer, size_t Count) { size_t writtenbytes; #ifdef _WIN32 - writtenbytes= my_win_write(Filedes, Buffer, Count); + writtenbytes= (size_t)_write(Filedes, Buffer, (unsigned int)Count); #else writtenbytes= write(Filedes, Buffer, Count); #endif @@ -152,10 +153,29 @@ static File loc_open(const char *FileName, int Flags) /* Special flags */ { File fd; -#if defined(_WIN32) - fd= my_win_open(FileName, Flags); +#ifdef _WIN32 + HANDLE h; + /* + We could just use _open() here. but prefer to open in unix-similar way + just like my_open() does it on Windows. + This gives atomic multiprocess-safe appends, and possibility to rename + or even delete file while it is open, and CRT lacks this features. + */ + assert(Flags == (O_APPEND | O_CREAT | O_WRONLY)); + h= CreateFile(FileName, FILE_APPEND_DATA, + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (h == INVALID_HANDLE_VALUE) + { + fd= -1; + my_osmaperr(GetLastError()); + } + else + { + fd= _open_osfhandle((intptr)h, O_WRONLY|O_BINARY); + } #else - fd = open(FileName, Flags, my_umask); + fd= open(FileName, Flags, my_umask); #endif my_errno= errno; return fd; @@ -171,7 +191,7 @@ static int loc_close(File fd) err= close(fd); } while (err == -1 && errno == EINTR); #else - err= my_win_close(fd); + err= close(fd); #endif my_errno=errno; return err; @@ -201,32 +221,9 @@ static int loc_rename(const char *from, const char *to) } -static my_off_t loc_seek(File fd, my_off_t pos, int whence) -{ - os_off_t newpos= -1; -#ifdef _WIN32 - newpos= my_win_lseek(fd, pos, whence); -#else - newpos= lseek(fd, pos, whence); -#endif - if (newpos == (os_off_t) -1) - { - my_errno= errno; - return MY_FILEPOS_ERROR; - } - - return (my_off_t) newpos; -} - - static my_off_t loc_tell(File fd) { - os_off_t pos; -#if defined (HAVE_TELL) && !defined (_WIN32) - pos= tell(fd); -#else - pos= loc_seek(fd, 0L, MY_SEEK_CUR); -#endif + os_off_t pos= IF_WIN(_telli64(fd),lseek(fd, 0, SEEK_CUR)); if (pos == (os_off_t) -1) { my_errno= errno; @@ -990,7 +987,7 @@ static int start_logging() if (output_type == OUTPUT_FILE) { char alt_path_buffer[FN_REFLEN+1+DEFAULT_FILENAME_LEN]; - MY_STAT *f_stat; + struct stat *f_stat= (struct stat *)alt_path_buffer; const char *alt_fname= file_path; while (*alt_fname == ' ') @@ -1005,7 +1002,7 @@ static int start_logging() { /* See if the directory exists with the name of file_path. */ /* Log file name should be [file_path]/server_audit.log then. */ - if ((f_stat= my_stat(file_path, (MY_STAT *)alt_path_buffer, MYF(0))) && + if (stat(file_path, (struct stat *)alt_path_buffer) == 0 && S_ISDIR(f_stat->st_mode)) { size_t p_len= strlen(file_path); @@ -1421,7 +1418,7 @@ static size_t escape_string_hide_passwords(const char *str, unsigned int len, } next_s++; } - len-= next_s - str; + len-= (uint)(next_s - str); str= next_s; continue; } diff --git a/plugin/userstat/index_stats.cc b/plugin/userstat/index_stats.cc index 236130d327f..87e6da63e38 100644 --- a/plugin/userstat/index_stats.cc +++ b/plugin/userstat/index_stats.cc @@ -35,11 +35,11 @@ static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond) index_name_length= (index_stats->index_name_length - schema_name_length - table_name_length - 3); - table->field[0]->store(tmp_table.db, schema_name_length, + table->field[0]->store(tmp_table.db, (uint)schema_name_length, system_charset_info); - table->field[1]->store(tmp_table.table_name, table_name_length, + table->field[1]->store(tmp_table.table_name, (uint) table_name_length, system_charset_info); - table->field[2]->store(index_name, index_name_length, system_charset_info); + table->field[2]->store(index_name, (uint) index_name_length, system_charset_info); table->field[3]->store((longlong)index_stats->rows_read, TRUE); if (schema_table_store_record(thd, table)) |