Skip to content

Commit 49c138c

Browse files
sferiknobu
authored andcommitted
Check dump size in ibf_dump_write
1 parent 0828dff commit 49c138c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compile.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12602,8 +12602,13 @@ static ibf_offset_t
1260212602
ibf_dump_write(struct ibf_dump *dump, const void *buff, unsigned long size)
1260312603
{
1260412604
ibf_offset_t pos = ibf_dump_pos(dump);
12605+
#if SIZEOF_LONG > SIZEOF_INT
12606+
/* ensure the resulting dump does not exceed UINT_MAX */
12607+
if (size >= UINT_MAX || pos + size >= UINT_MAX) {
12608+
rb_raise(rb_eRuntimeError, "dump size exceeds");
12609+
}
12610+
#endif
1260512611
rb_str_cat(dump->current_buffer->str, (const char *)buff, size);
12606-
/* TODO: overflow check */
1260712612
return pos;
1260812613
}
1260912614

0 commit comments

Comments
 (0)