Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
7e64d7e5
Commit
7e64d7e5
authored
Nov 10, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check for corrupted mrb file data
parent
29792d17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
src/load.c
src/load.c
+15
-8
No files found.
src/load.c
View file @
7e64d7e5
...
@@ -406,7 +406,7 @@ mrb_irep*
...
@@ -406,7 +406,7 @@ mrb_irep*
mrb_read_irep
(
mrb_state
*
mrb
,
const
uint8_t
*
bin
)
mrb_read_irep
(
mrb_state
*
mrb
,
const
uint8_t
*
bin
)
{
{
int
result
;
int
result
;
mrb_irep
*
irep
;
mrb_irep
*
irep
=
NULL
;
const
struct
rite_section_header
*
section_header
;
const
struct
rite_section_header
*
section_header
;
uint16_t
crc
;
uint16_t
crc
;
size_t
bin_size
=
0
;
size_t
bin_size
=
0
;
...
@@ -434,12 +434,14 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
...
@@ -434,12 +434,14 @@ mrb_read_irep(mrb_state *mrb, const uint8_t *bin)
if
(
!
irep
)
return
NULL
;
if
(
!
irep
)
return
NULL
;
}
}
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_LINENO_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_LINENO_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
if
(
!
irep
)
return
NULL
;
/* corrupted data */
result
=
read_section_lineno
(
mrb
,
bin
,
irep
);
result
=
read_section_lineno
(
mrb
,
bin
,
irep
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
NULL
;
return
NULL
;
}
}
}
}
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_DEBUG_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
->
section_identify
,
RITE_SECTION_DEBUG_IDENTIFIER
,
sizeof
(
section_header
->
section_identify
))
==
0
)
{
if
(
!
irep
)
return
NULL
;
/* corrupted data */
result
=
read_section_debug
(
mrb
,
bin
,
irep
);
result
=
read_section_debug
(
mrb
,
bin
,
irep
);
if
(
result
<
MRB_DUMP_OK
)
{
if
(
result
<
MRB_DUMP_OK
)
{
return
NULL
;
return
NULL
;
...
@@ -602,7 +604,7 @@ read_section_irep_file(mrb_state *mrb, FILE *fp)
...
@@ -602,7 +604,7 @@ read_section_irep_file(mrb_state *mrb, FILE *fp)
mrb_irep
*
mrb_irep
*
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
{
mrb_irep
*
irep
;
mrb_irep
*
irep
=
NULL
;
int
result
;
int
result
;
uint8_t
*
buf
;
uint8_t
*
buf
;
uint16_t
crc
,
crcwk
=
0
;
uint16_t
crc
,
crcwk
=
0
;
...
@@ -671,12 +673,16 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
...
@@ -671,12 +673,16 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
if
(
!
irep
)
return
NULL
;
if
(
!
irep
)
return
NULL
;
}
}
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_LINENO_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_LINENO_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
if
(
!
irep
)
return
NULL
;
/* corrupted data */
fseek
(
fp
,
fpos
,
SEEK_SET
);
fseek
(
fp
,
fpos
,
SEEK_SET
);
result
=
read_section_lineno_file
(
mrb
,
fp
,
irep
);
result
=
read_section_lineno_file
(
mrb
,
fp
,
irep
);
if
(
result
<
MRB_DUMP_OK
)
return
NULL
;
if
(
result
<
MRB_DUMP_OK
)
return
NULL
;
}
}
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_DEBUG_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
else
if
(
memcmp
(
section_header
.
section_identify
,
RITE_SECTION_DEBUG_IDENTIFIER
,
sizeof
(
section_header
.
section_identify
))
==
0
)
{
if
(
!
irep
)
return
NULL
;
/* corrupted data */
else
{
uint8_t
*
const
bin
=
mrb_malloc
(
mrb
,
section_size
);
uint8_t
*
const
bin
=
mrb_malloc
(
mrb
,
section_size
);
fseek
(
fp
,
fpos
,
SEEK_SET
);
fseek
(
fp
,
fpos
,
SEEK_SET
);
if
(
fread
((
char
*
)
bin
,
section_size
,
1
,
fp
)
!=
1
)
{
if
(
fread
((
char
*
)
bin
,
section_size
,
1
,
fp
)
!=
1
)
{
mrb_free
(
mrb
,
bin
);
mrb_free
(
mrb
,
bin
);
...
@@ -684,6 +690,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
...
@@ -684,6 +690,7 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
}
}
result
=
read_section_debug
(
mrb
,
bin
,
irep
);
result
=
read_section_debug
(
mrb
,
bin
,
irep
);
mrb_free
(
mrb
,
bin
);
mrb_free
(
mrb
,
bin
);
}
if
(
result
<
MRB_DUMP_OK
)
return
NULL
;
if
(
result
<
MRB_DUMP_OK
)
return
NULL
;
}
}
...
...
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