Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
37379ef0
Commit
37379ef0
authored
Apr 09, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit frm size, when reading it in memory
parent
e71cda83
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
sql/discover.cc
sql/discover.cc
+1
-1
sql/table.cc
sql/table.cc
+6
-3
sql/unireg.h
sql/unireg.h
+1
-0
No files found.
sql/discover.cc
View file @
37379ef0
...
@@ -70,7 +70,7 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
...
@@ -70,7 +70,7 @@ int readfrm(const char *name, const uchar **frmdata, size_t *len)
error
=
2
;
error
=
2
;
if
(
mysql_file_fstat
(
file
,
&
state
,
MYF
(
0
)))
if
(
mysql_file_fstat
(
file
,
&
state
,
MYF
(
0
)))
goto
err
;
goto
err
;
read_len
=
(
size_t
)
state
.
st_size
;
read_len
=
(
size_t
)
min
(
FRM_MAX_SIZE
,
state
.
st_size
);
// safety
// Read whole frm file
// Read whole frm file
error
=
3
;
error
=
3
;
...
...
sql/table.cc
View file @
37379ef0
...
@@ -596,6 +596,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
...
@@ -596,6 +596,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
uchar
*
buf
;
uchar
*
buf
;
uchar
head
[
FRM_HEADER_SIZE
];
uchar
head
[
FRM_HEADER_SIZE
];
char
path
[
FN_REFLEN
];
char
path
[
FN_REFLEN
];
size_t
frmlen
;
DBUG_ENTER
(
"open_table_def"
);
DBUG_ENTER
(
"open_table_def"
);
DBUG_PRINT
(
"enter"
,
(
"table: '%s'.'%s' path: '%s'"
,
share
->
db
.
str
,
DBUG_PRINT
(
"enter"
,
(
"table: '%s'.'%s' path: '%s'"
,
share
->
db
.
str
,
share
->
table_name
.
str
,
share
->
normalized_path
.
str
));
share
->
table_name
.
str
,
share
->
normalized_path
.
str
));
...
@@ -642,13 +643,15 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
...
@@ -642,13 +643,15 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
if
(
my_fstat
(
file
,
&
stats
,
MYF
(
0
)))
if
(
my_fstat
(
file
,
&
stats
,
MYF
(
0
)))
goto
err
;
goto
err
;
if
(
!
(
buf
=
(
uchar
*
)
my_malloc
(
stats
.
st_size
,
MYF
(
MY_THREAD_SPECIFIC
|
MY_WME
))))
frmlen
=
min
(
FRM_MAX_SIZE
,
stats
.
st_size
);
// safety
if
(
!
(
buf
=
(
uchar
*
)
my_malloc
(
frmlen
,
MYF
(
MY_THREAD_SPECIFIC
|
MY_WME
))))
goto
err
;
goto
err
;
memcpy
(
buf
,
head
,
sizeof
(
head
));
memcpy
(
buf
,
head
,
sizeof
(
head
));
if
(
mysql_file_read
(
file
,
buf
+
sizeof
(
head
),
if
(
mysql_file_read
(
file
,
buf
+
sizeof
(
head
),
stats
.
st_size
-
sizeof
(
head
),
MYF
(
MY_NABP
)))
frmlen
-
sizeof
(
head
),
MYF
(
MY_NABP
)))
{
{
share
->
error
=
my_errno
==
HA_ERR_FILE_TOO_SHORT
share
->
error
=
my_errno
==
HA_ERR_FILE_TOO_SHORT
?
OPEN_FRM_CORRUPTED
:
OPEN_FRM_READ_ERROR
;
?
OPEN_FRM_CORRUPTED
:
OPEN_FRM_READ_ERROR
;
...
@@ -657,7 +660,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
...
@@ -657,7 +660,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
}
}
mysql_file_close
(
file
,
MYF
(
MY_WME
));
mysql_file_close
(
file
,
MYF
(
MY_WME
));
share
->
init_from_binary_frm_image
(
thd
,
false
,
buf
,
stats
.
st_size
);
share
->
init_from_binary_frm_image
(
thd
,
false
,
buf
,
frmlen
);
error_given
=
true
;
// init_from_binary_frm_image has already called my_error()
error_given
=
true
;
// init_from_binary_frm_image has already called my_error()
my_free
(
buf
);
my_free
(
buf
);
...
...
sql/unireg.h
View file @
37379ef0
...
@@ -193,6 +193,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
...
@@ -193,6 +193,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table,
#define FRM_HEADER_SIZE 64
#define FRM_HEADER_SIZE 64
#define FRM_FORMINFO_SIZE 288
#define FRM_FORMINFO_SIZE 288
#define FRM_MAX_SIZE (256*1024)
static
inline
bool
is_binary_frm_header
(
uchar
*
head
)
static
inline
bool
is_binary_frm_header
(
uchar
*
head
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment