mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
load.c: fix off-by-one in bounds check for pool strings
The bounds check for IREP_TT_STR pool data only validated pool_data_len bytes, but the binary format includes a null terminator after the string content. Both memcpy and the source pointer advance by pool_data_len+1, so the check must account for the extra byte. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -189,7 +189,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, const uint8_t *end, size_
|
||||
case IREP_TT_STR:
|
||||
pool_data_len = bin_to_uint16(src); /* pool data length */
|
||||
src += sizeof(uint16_t);
|
||||
if (src + pool_data_len > end) return FALSE;
|
||||
if (src + pool_data_len + 1 > end) return FALSE;
|
||||
if (st) {
|
||||
pool[i].tt = (pool_data_len<<2) | IREP_TT_SSTR;
|
||||
pool[i].u.str = (const char*)src;
|
||||
|
||||
Reference in New Issue
Block a user