List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:December 16 2010 5:17pm
Subject:bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3521) Bug#57450
View as plain text  
#At file:///Users/shulga/projects/mysql/5.1-bugteam-bug57450/ based on revid:azundris@stripped

 3521 Dmitry Shulga	2010-12-16
      Fixed bug#57450	- mysql client enter in an infinite loop
      if the standard input is a directory.
      
      The problem is that mysql monitor try to read from stdin without
      checking for type of input source.
      
      The solution is to check if stdin's file descriptor related to directory
      and exit from program if this case is true.
      
      Additionally, it was fixed a bug in processing of error returned by
      read syscal.
     @ client/readline.cc
        batch_readline_init() was modified: added checking for file mode
        and returning from function if input stream is a directory.
        
        intern_read_line() was modified: cancel reading from input if
        fill_buffer() returns -1, e.g. if call to read failed.

    modified:
      client/mysql.cc
      client/readline.cc
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2010-10-19 22:36:59 +0000
+++ b/client/mysql.cc	2010-12-16 17:16:56 +0000
@@ -1131,6 +1131,7 @@ 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", INFO_ERROR, 0);
     free_defaults(defaults_argv);
     my_end(0);
     exit(1);

=== modified file 'client/readline.cc'
--- a/client/readline.cc	2009-03-18 08:27:49 +0000
+++ b/client/readline.cc	2010-12-16 17:16:56 +0000
@@ -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_BUFFE
 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;
@@ -218,11 +226,13 @@ char *intern_read_line(LINE_BUFFER *buff
         or when the internal buffer has hit the size limit. In the latter case
         return what we have read so far and signal string truncation.
       */
-      if (!(length=fill_buffer(buffer)) || length == (uint) -1)
+      if (!(length=fill_buffer(buffer)))
       {
         if (buffer->eof)
           DBUG_RETURN(0);
       }
+      else if (length == (uint) -1)
+        DBUG_RETURN(0);
       else
         continue;
       pos--;					/* break line here */


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@oracle.com-20101216171656-bdqr5w1jb2fp4ajp.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3521) Bug#57450Dmitry Shulga16 Dec
  • Re: bzr commit into mysql-5.1-bugteam branch (Dmitry.Shulga:3521)Bug#57450Davi Arnaut10 Jan