diff options
author | Dmitry Shulga <Dmitry.Shulga@oracle.com> | 2011-02-09 12:46:12 +0600 |
---|---|---|
committer | Dmitry Shulga <Dmitry.Shulga@oracle.com> | 2011-02-09 12:46:12 +0600 |
commit | c46e20f6c1275df5890838f92dc070fc7de99f63 (patch) | |
tree | 71e6ff6472855ba18820b385112efadfb918d07b /client | |
parent | aa7a928502520cfa05af7c3d5daaa556f52e949c (diff) | |
download | mariadb-git-c46e20f6c1275df5890838f92dc070fc7de99f63.tar.gz |
Follow up fix for bug#57450.
batch_readline_init() was modified - return an error
if the input source is a directory or a block device.
This follow-up is necessary because on some platforms,
such as Solaris, call to read() from directory may be
successful.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 2 | ||||
-rw-r--r-- | client/readline.cc | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index b19aaf61e58..e7e7b244a49 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1131,6 +1131,8 @@ int main(int argc,char *argv[]) if (status.batch && !status.line_buff && !(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin))) { + put_info("Can't initialize batch_readline - may be the input source is " + "a directory or a block device.", INFO_ERROR, 0); free_defaults(defaults_argv); my_end(0); exit(1); diff --git a/client/readline.cc b/client/readline.cc index 7f283502ecb..9ac9ea5824e 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -18,6 +18,7 @@ #include <my_global.h> #include <my_sys.h> #include <m_string.h> +#include <my_dir.h> #include "my_readline.h" static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size, @@ -30,6 +31,13 @@ static char *intern_read_line(LINE_BUFFER *buffer, ulong *out_length); LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) { LINE_BUFFER *line_buff; + MY_STAT input_file_stat; + + if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) || + MY_S_ISDIR(input_file_stat.st_mode) || + MY_S_ISBLK(input_file_stat.st_mode)) + return 0; + if (!(line_buff=(LINE_BUFFER*) my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL)))) return 0; |