diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-11-04 02:41:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-11-04 02:41:42 +0900 |
| commit | be844f9284c692355189165a7a2fc19ecaebb1f6 (patch) | |
| tree | 1d07de9b51e3200982ef09a3e56cae866119338c /src/load.c | |
| parent | 23db5331a670f31b314ce178515cc8de625324dc (diff) | |
| download | mruby-be844f9284c692355189165a7a2fc19ecaebb1f6.tar.gz mruby-be844f9284c692355189165a7a2fc19ecaebb1f6.zip | |
Fix misaligned access when reading irep; close #2630
Add padding bytes before iseq block that may be used as mrb_code[].
Note that dumped mrb format has changed.
Based on a patch from kimu_shu <[email protected]>
Diffstat (limited to 'src/load.c')
| -rw-r--r-- | src/load.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/load.c b/src/load.c index 5c42eb2bd..e0620a964 100644 --- a/src/load.c +++ b/src/load.c @@ -32,6 +32,13 @@ #endif static size_t +skip_padding(const uint8_t *buf) +{ + const size_t align = MRB_DUMP_ALIGNMENT; + return -(intptr_t)buf & (align-1); +} + +static size_t offset_crc_body(void) { struct rite_binary_header header; @@ -68,6 +75,8 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag /* ISEQ BLOCK */ irep->ilen = (size_t)bin_to_uint32(src); src += sizeof(uint32_t); + src += skip_padding(src); + if (irep->ilen > 0) { if (SIZE_ERROR_MUL(sizeof(mrb_code), irep->ilen)) { return NULL; |
