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
5e9689c4
Commit
5e9689c4
authored
Aug 30, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2576 from cremno/correctly-validate-symbol-length
correctly validate symbol length
parents
607795ff
c219c2a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
src/symbol.c
src/symbol.c
+12
-6
No files found.
src/symbol.c
View file @
5e9689c4
...
...
@@ -9,6 +9,7 @@
#include "mruby.h"
#include "mruby/khash.h"
#include "mruby/string.h"
#include "mruby/dump.h"
/* ------------------------------------------------------ */
typedef
struct
symbol_name
{
...
...
@@ -34,6 +35,15 @@ sym_hash_func(mrb_state *mrb, const symbol_name s)
KHASH_DECLARE
(
n2s
,
symbol_name
,
mrb_sym
,
TRUE
)
KHASH_DEFINE
(
n2s
,
symbol_name
,
mrb_sym
,
TRUE
,
sym_hash_func
,
sym_hash_equal
)
/* ------------------------------------------------------ */
static
void
sym_validate_len
(
mrb_state
*
mrb
,
size_t
len
)
{
if
(
len
>=
RITE_LV_NULL_MARK
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"symbol length too long"
);
}
}
static
mrb_sym
sym_intern
(
mrb_state
*
mrb
,
const
char
*
name
,
size_t
len
,
mrb_bool
lit
)
{
...
...
@@ -43,9 +53,7 @@ sym_intern(mrb_state *mrb, const char *name, size_t len, mrb_bool lit)
mrb_sym
sym
;
char
*
p
;
if
(
len
>
(
UINT16_MAX
-
1
))
{
/* UINT16_MAX is reverved */
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"symbol length too long"
);
}
sym_validate_len
(
mrb
,
len
);
sname
.
lit
=
lit
;
sname
.
len
=
(
uint16_t
)
len
;
sname
.
name
=
name
;
...
...
@@ -100,9 +108,7 @@ mrb_check_intern(mrb_state *mrb, const char *name, size_t len)
symbol_name
sname
=
{
0
};
khiter_t
k
;
if
(
len
>
UINT16_MAX
)
{
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"symbol length too long"
);
}
sym_validate_len
(
mrb
,
len
);
sname
.
len
=
(
uint16_t
)
len
;
sname
.
name
=
name
;
...
...
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