Commit cda52b2c authored by Sergei Golubchik's avatar Sergei Golubchik

remove dead HAVE_CRYPTED_FRM code

and now-unused read_string() function
parent 0d1a5958
...@@ -74,9 +74,13 @@ int readfrm(const char *name, uchar **frmdata, size_t *len) ...@@ -74,9 +74,13 @@ int readfrm(const char *name, uchar **frmdata, size_t *len)
// Read whole frm file // Read whole frm file
error= 3; error= 3;
read_data= 0; // Nothing to free if (!(read_data= (uchar*)my_malloc(read_len, MYF(MY_WME))))
if (read_string(file, &read_data, read_len))
goto err; goto err;
if (mysql_file_read(file, read_data, read_len, MYF(MY_NABP)))
{
my_free(read_data);
goto err;
}
// Setup return data // Setup return data
*frmdata= (uchar*) read_data; *frmdata= (uchar*) read_data;
......
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/*
** change the following to the output of password('our password')
** split into 2 parts of 8 characters each.
** This is done to make it impossible to search after a text string in the
** mysql binary.
*/
#include "sql_priv.h"
#include "frm_crypt.h"
#ifdef HAVE_CRYPTED_FRM
/* password('test') */
ulong password_seed[2]={0x378b243e, 0x220ca493};
SQL_CRYPT *get_crypt_for_frm(void)
{
return new SQL_CRYPT(password_seed);
}
#endif
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef FRM_CRYPT_INCLUDED
#define FRM_CRYPT_INCLUDED
class SQL_CRYPT;
SQL_CRYPT *get_crypt_for_frm(void);
#endif /* FRM_CRYPT_INCLUDED */
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "sql_priv.h" #include "sql_priv.h"
#include "unireg.h" // REQUIRED: for other includes #include "unireg.h" // REQUIRED: for other includes
#include "table.h" #include "table.h"
#include "frm_crypt.h" // get_crypt_for_frm
#include "key.h" // find_ref_key #include "key.h" // find_ref_key
#include "sql_table.h" // build_table_filename, #include "sql_table.h" // build_table_filename,
// primary_key_name // primary_key_name
...@@ -806,7 +805,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image) ...@@ -806,7 +805,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image)
handler *handler_file= 0; handler *handler_file= 0;
KEY *keyinfo; KEY *keyinfo;
KEY_PART_INFO *key_part= NULL; KEY_PART_INFO *key_part= NULL;
SQL_CRYPT *crypted=0;
Field **field_ptr, *reg_field; Field **field_ptr, *reg_field;
const char **interval_array; const char **interval_array;
enum legacy_db_type legacy_db_type; enum legacy_db_type legacy_db_type;
...@@ -1070,13 +1068,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image) ...@@ -1070,13 +1068,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image)
share->stored_rec_length= share->reclength; share->stored_rec_length= share->reclength;
if (*(frm_image+26) == 1) if (*(frm_image+26) == 1)
share->system= 1; /* one-record-database */ share->system= 1; /* one-record-database */
#ifdef HAVE_CRYPTED_FRM
else if (*(frm_image+26) == 2)
{
crypted= get_crypt_for_frm();
share->crypted= 1;
}
#endif
record_offset= (ulong) (uint2korr(frm_image+6)+ record_offset= (ulong) (uint2korr(frm_image+6)+
((uint2korr(frm_image+14) == 0xffff ? ((uint2korr(frm_image+14) == 0xffff ?
...@@ -1265,15 +1256,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image) ...@@ -1265,15 +1256,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image)
disk_buff= frm_image + pos + 288; disk_buff= frm_image + pos + 288;
#ifdef HAVE_CRYPTED_FRM
if (crypted)
{
crypted->decode((char*) forminfo+256,288-256);
if (sint2korr(forminfo+284) != 0) // Should be 0
goto err; // Wrong password
}
#endif
share->fields= uint2korr(forminfo+258); share->fields= uint2korr(forminfo+258);
pos= uint2korr(forminfo+260); /* Length of all screens */ pos= uint2korr(forminfo+260); /* Length of all screens */
n_length= uint2korr(forminfo+268); n_length= uint2korr(forminfo+268);
...@@ -1310,14 +1292,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image) ...@@ -1310,14 +1292,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image)
read_length=(uint) (share->fields * field_pack_length + read_length=(uint) (share->fields * field_pack_length +
pos+ (uint) (n_length+int_length+com_length+ pos+ (uint) (n_length+int_length+com_length+
vcol_screen_length)); vcol_screen_length));
#ifdef HAVE_CRYPTED_FRM
if (crypted)
{
crypted->decode((char*) disk_buff,read_length);
delete crypted;
crypted=0;
}
#endif
strpos= disk_buff+pos; strpos= disk_buff+pos;
share->intervals= (TYPELIB*) (field_ptr+share->fields+1); share->intervals= (TYPELIB*) (field_ptr+share->fields+1);
...@@ -2012,7 +1986,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image) ...@@ -2012,7 +1986,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *frm_image)
share->error= error; share->error= error;
share->open_errno= my_errno; share->open_errno= my_errno;
share->errarg= errarg; share->errarg= errarg;
delete crypted;
delete handler_file; delete handler_file;
my_hash_free(&share->name_hash); my_hash_free(&share->name_hash);
if (share->ha_data_destroy) if (share->ha_data_destroy)
...@@ -2823,30 +2796,6 @@ void free_field_buffers_larger_than(TABLE *table, uint32 size) ...@@ -2823,30 +2796,6 @@ void free_field_buffers_larger_than(TABLE *table, uint32 size)
} }
} }
/*
Read string from a file with malloc
NOTES:
We add an \0 at end of the read string to make reading of C strings easier
*/
int read_string(File file, uchar**to, size_t length)
{
DBUG_ENTER("read_string");
my_free(*to);
if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) ||
mysql_file_read(file, *to, length, MYF(MY_NABP)))
{
my_free(*to); /* purecov: inspected */
*to= 0; /* purecov: inspected */
DBUG_RETURN(1); /* purecov: inspected */
}
*((char*) *to+length)= '\0';
DBUG_RETURN (0);
} /* read_string */
/* Add a new form to a form file */ /* Add a new form to a form file */
ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames, ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames,
......
...@@ -2463,7 +2463,6 @@ char *get_field(MEM_ROOT *mem, Field *field); ...@@ -2463,7 +2463,6 @@ char *get_field(MEM_ROOT *mem, Field *field);
bool get_field(MEM_ROOT *mem, Field *field, class String *res); bool get_field(MEM_ROOT *mem, Field *field, class String *res);
int closefrm(TABLE *table, bool free_share); int closefrm(TABLE *table, bool free_share);
int read_string(File file, uchar* *to, size_t length);
void free_blobs(TABLE *table); void free_blobs(TABLE *table);
void free_field_buffers_larger_than(TABLE *table, uint32 size); void free_field_buffers_larger_than(TABLE *table, uint32 size);
int set_zone(int nr,int min_zone,int max_zone); int set_zone(int nr,int min_zone,int max_zone);
......
...@@ -396,28 +396,6 @@ bool mysql_create_frm(THD *thd, const char *file_name, ...@@ -396,28 +396,6 @@ bool mysql_create_frm(THD *thd, const char *file_name,
pack_fields(file, create_fields, data_offset)) pack_fields(file, create_fields, data_offset))
goto err; goto err;
#ifdef HAVE_CRYPTED_FRM
if (create_info->password)
{
char tmp=2,*disk_buff=0;
SQL_CRYPT *crypted=new SQL_CRYPT(create_info->password);
if (!crypted || mysql_file_pwrite(file, &tmp, 1, 26, MYF_RW))// Mark crypted
goto err;
uint read_length=uint2korr(forminfo)-256;
mysql_file_seek(file, filepos+256, MY_SEEK_SET, MYF(0));
if (read_string(file,(uchar**) &disk_buff,read_length))
goto err;
crypted->encode(disk_buff,read_length);
delete crypted;
if (mysql_file_pwrite(file, disk_buff, read_length, filepos+256, MYF_RW))
{
my_free(disk_buff);
goto err;
}
my_free(disk_buff);
}
#endif
my_free(screen_buff); my_free(screen_buff);
my_free(keybuff); my_free(keybuff);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment