Skip to content

Commit c6a37a6

Browse files
nobumame
authored andcommitted
Fix integer overflow
Make use of the check in rb_alloc_tmp_buffer2. https://hackerone.com/reports/1328463
1 parent 8f0b257 commit c6a37a6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

ext/cgi/escape/escape.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static VALUE
3636
optimized_escape_html(VALUE str)
3737
{
3838
VALUE vbuf;
39-
char *buf = ALLOCV_N(char, vbuf, RSTRING_LEN(str) * HTML_ESCAPE_MAX_LEN);
39+
typedef char escape_buf[HTML_ESCAPE_MAX_LEN];
40+
char *buf = *ALLOCV_N(escape_buf, vbuf, RSTRING_LEN(str));
4041
const char *cstr = RSTRING_PTR(str);
4142
const char *end = cstr + RSTRING_LEN(str);
4243

0 commit comments

Comments
 (0)