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
bfd11aab
Commit
bfd11aab
authored
Jul 31, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check size of the integer multiply before actual overflow; fix #4062
parent
d8866766
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
mrbgems/mruby-sprintf/src/sprintf.c
mrbgems/mruby-sprintf/src/sprintf.c
+3
-6
No files found.
mrbgems/mruby-sprintf/src/sprintf.c
View file @
bfd11aab
...
@@ -119,13 +119,11 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
...
@@ -119,13 +119,11 @@ mrb_fix2binstr(mrb_state *mrb, mrb_value x, int base)
#define FPREC0 128
#define FPREC0 128
#define CHECK(l) do {\
#define CHECK(l) do {\
/* int cr = ENC_CODERANGE(result);*/
\
while ((l) >= bsiz - blen) {\
while ((l) >= bsiz - blen) {\
if (bsiz > MRB_INT_MAX/2) mrb_raise(mrb, E_ARGUMENT_ERROR, "too big specifier"); \
bsiz*=2;\
bsiz*=2;\
if (bsiz < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, "too big specifier"); \
}\
}\
mrb_str_resize(mrb, result, bsiz);\
mrb_str_resize(mrb, result, bsiz);\
/* ENC_CODERANGE_SET(result, cr);*/
\
buf = RSTRING_PTR(result);\
buf = RSTRING_PTR(result);\
} while (0)
} while (0)
...
@@ -202,11 +200,10 @@ check_name_arg(mrb_state *mrb, int posarg, const char *name, mrb_int len)
...
@@ -202,11 +200,10 @@ check_name_arg(mrb_state *mrb, int posarg, const char *name, mrb_int len)
#define GETNUM(n, val) \
#define GETNUM(n, val) \
for (; p < end && ISDIGIT(*p); p++) {\
for (; p < end && ISDIGIT(*p); p++) {\
mrb_int next_n = 10 * n + (*p - '0'); \
if (n > MRB_INT_MAX/10) {\
if (next_n / 10 != n) {\
mrb_raise(mrb, E_ARGUMENT_ERROR, #val " too big"); \
mrb_raise(mrb, E_ARGUMENT_ERROR, #val " too big"); \
} \
} \
n =
next_n
; \
n =
10 * n + (*p - '0')
; \
} \
} \
if (p >= end) { \
if (p >= end) { \
mrb_raise(mrb, E_ARGUMENT_ERROR, "malformed format string - %*[0-9]"); \
mrb_raise(mrb, E_ARGUMENT_ERROR, "malformed format string - %*[0-9]"); \
...
...
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