... | ... |
@@ -265,7 +265,16 @@ static int riff_read_chunk(fmap_t *map, off_t *offset, int big_endian, int rec_l |
265 | 265 |
if(!(buf = fmap_need_off_once(map, cur_offset, 4*2))) |
266 | 266 |
return 0; |
267 | 267 |
cur_offset += 4*2; |
268 |
- chunk_size = riff_endian_convert_32(buf[1], big_endian); |
|
268 |
+ |
|
269 |
+ /* Fix possible alignment issues */ |
|
270 |
+ { |
|
271 |
+ uint32_t cache_buf; |
|
272 |
+ void *buffer = buf; |
|
273 |
+ |
|
274 |
+ memcpy (&cache_buf, buffer + sizeof (cache_buf), |
|
275 |
+ sizeof (cache_buf)); |
|
276 |
+ chunk_size = riff_endian_convert_32(cache_buf, big_endian); |
|
277 |
+ } |
|
269 | 278 |
|
270 | 279 |
if(!memcmp(buf, "anih", 4) && chunk_size != 36) |
271 | 280 |
return 2; |