~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to sql/sql_load.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
 
1
/*
 
2
   Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
 
17
19
/* Copy data from a textfile to table */
314
316
      (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
315
317
                       MY_RELATIVE_PATH | MY_UNPACK_FILENAME |
316
318
                       MY_RETURN_REAL_PATH);
317
 
#if !defined(__WIN__) && ! defined(__NETWARE__)
318
 
      MY_STAT stat_info;
319
 
      if (!my_stat(name,&stat_info,MYF(MY_WME)))
320
 
        DBUG_RETURN(TRUE);
321
 
 
322
 
      // if we are not in slave thread, the file must be:
323
 
      if (!thd->slave_thread &&
324
 
          !((stat_info.st_mode & S_IROTH) == S_IROTH &&  // readable by others
325
 
            (stat_info.st_mode & S_IFLNK) != S_IFLNK && // and not a symlink
326
 
            ((stat_info.st_mode & S_IFREG) == S_IFREG ||
327
 
             (stat_info.st_mode & S_IFIFO) == S_IFIFO)))
328
 
      {
329
 
        my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
330
 
        DBUG_RETURN(TRUE);
331
 
      }
332
 
      if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
333
 
        is_fifo = 1;
334
 
#endif
335
 
 
336
 
      if (thd->slave_thread)
337
 
      {
 
319
    }
 
320
 
 
321
    if (thd->slave_thread)
 
322
    {
338
323
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
339
 
        if (strncmp(active_mi->rli.slave_patternload_file, name, 
340
 
            active_mi->rli.slave_patternload_file_size))
341
 
        {
342
 
          /*
343
 
            LOAD DATA INFILE in the slave SQL Thread can only read from 
344
 
            --slave-load-tmpdir". This should never happen. Please, report a bug.
345
 
           */
346
 
 
347
 
          sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
348
 
                          "Please, report a bug.");
349
 
          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
350
 
          DBUG_RETURN(TRUE);
351
 
        }
352
 
#else
 
324
      if (strncmp(active_mi->rli.slave_patternload_file, name, 
 
325
          active_mi->rli.slave_patternload_file_size))
 
326
      {
353
327
        /*
354
 
          This is impossible and should never happen.
 
328
          LOAD DATA INFILE in the slave SQL Thread can only read from 
 
329
          --slave-load-tmpdir". This should never happen. Please, report a bug.
355
330
        */
356
 
        DBUG_ASSERT(FALSE); 
357
 
#endif
358
 
      }
359
 
      else if (!is_secure_file_path(name))
360
 
      {
361
 
        /* Read only allowed from within dir specified by secure_file_priv */
362
 
        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
 
331
 
 
332
        sql_print_error("LOAD DATA INFILE in the slave SQL Thread can only read from --slave-load-tmpdir. " \
 
333
                        "Please, report a bug.");
 
334
        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--slave-load-tmpdir");
363
335
        DBUG_RETURN(TRUE);
364
336
      }
365
 
 
366
 
    }
 
337
#else
 
338
      /*
 
339
        This is impossible and should never happen.
 
340
      */
 
341
      DBUG_ASSERT(FALSE); 
 
342
#endif
 
343
    }
 
344
    else if (!is_secure_file_path(name))
 
345
    {
 
346
      /* Read only allowed from within dir specified by secure_file_priv */
 
347
      my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
 
348
      DBUG_RETURN(TRUE);
 
349
    }
 
350
 
 
351
#if !defined(__WIN__) && ! defined(__NETWARE__)
 
352
    MY_STAT stat_info;
 
353
    if (!my_stat(name, &stat_info, MYF(MY_WME)))
 
354
      DBUG_RETURN(TRUE);
 
355
 
 
356
    // if we are not in slave thread, the file must be:
 
357
    if (!thd->slave_thread &&
 
358
        !((stat_info.st_mode & S_IROTH) == S_IROTH &&  // readable by others
 
359
          (stat_info.st_mode & S_IFLNK) != S_IFLNK &&  // and not a symlink
 
360
          ((stat_info.st_mode & S_IFREG) == S_IFREG || // and a regular file
 
361
           (stat_info.st_mode & S_IFIFO) == S_IFIFO))) // or FIFO
 
362
    {
 
363
      my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), name);
 
364
      DBUG_RETURN(TRUE);
 
365
    }
 
366
    if ((stat_info.st_mode & S_IFIFO) == S_IFIFO)
 
367
      is_fifo= 1;
 
368
#endif
 
369
 
367
370
    if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
368
371
      DBUG_RETURN(TRUE);
369
372
  }
567
570
                                                  transactional_table,
568
571
                                                  errcode);
569
572
      }
 
573
 
 
574
      /*
 
575
        Flushing the IO CACHE while writing the execute load query log event
 
576
        may result in error (for instance, because the max_binlog_size has been 
 
577
        reached, and rotation of the binary log failed).
 
578
      */
 
579
      error= error || mysql_bin_log.get_log_file()->error;
570
580
    }
571
581
    if (error)
572
582
      goto err;
1067
1077
                     String &field_term, String &line_start, String &line_term,
1068
1078
                     String &enclosed_par, int escape, bool get_it_from_net,
1069
1079
                     bool is_fifo)
1070
 
  :file(file_par),escape_char(escape)
 
1080
  :file(file_par), buff_length(tot_length), escape_char(escape),
 
1081
   found_end_of_line(false), eof(false), need_end_io_cache(false),
 
1082
   error(false), line_cuted(false), found_null(false), read_charset(cs)
1071
1083
{
1072
 
  read_charset= cs;
1073
1084
  field_term_ptr=(char*) field_term.ptr();
1074
1085
  field_term_length= field_term.length();
1075
1086
  line_term_ptr=(char*) line_term.ptr();
1096
1107
    (uchar) enclosed_par[0] : INT_MAX;
1097
1108
  field_term_char= field_term_length ? (uchar) field_term_ptr[0] : INT_MAX;
1098
1109
  line_term_char= line_term_length ? (uchar) line_term_ptr[0] : INT_MAX;
1099
 
  error=eof=found_end_of_line=found_null=line_cuted=0;
1100
 
  buff_length=tot_length;
1101
1110
 
1102
1111
 
1103
1112
  /* Set of a stack for unget if long terminators */
1104
 
  uint length=max(field_term_length,line_term_length)+1;
 
1113
  uint length= max(cs->mbmaxlen, max(field_term_length, line_term_length)) + 1;
1105
1114
  set_if_bigger(length,line_start.length());
1106
1115
  stack=stack_pos=(int*) sql_alloc(sizeof(int)*length);
1107
1116
 
1143
1152
 
1144
1153
READ_INFO::~READ_INFO()
1145
1154
{
1146
 
  if (!error && need_end_io_cache)
 
1155
  if (need_end_io_cache)
1147
1156
    ::end_io_cache(&cache);
1148
1157
 
1149
1158
  my_free(buffer, MYF(MY_ALLOW_ZERO_PTR));