mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 05:49:51 +02:00
muxread,ChunkVerifyAndAssign: validate chunk_size
before accounting for padding which might overflow if chunk_size is > MAX_CHUNK_PAYLOAD. BUG=webp:387,webp:388 Change-Id: I3985b8817ed4faaec0629102c5333c228a0e9c98
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#ifndef WEBP_MUX_MUXI_H_
|
||||
#define WEBP_MUX_MUXI_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "src/dec/vp8i_dec.h"
|
||||
#include "src/dec/vp8li_dec.h"
|
||||
@ -143,13 +144,13 @@ void ChunkListDelete(WebPChunk** const chunk_list);
|
||||
|
||||
// Returns size of the chunk including chunk header and padding byte (if any).
|
||||
static WEBP_INLINE size_t SizeWithPadding(size_t chunk_size) {
|
||||
assert(chunk_size <= MAX_CHUNK_PAYLOAD);
|
||||
return CHUNK_HEADER_SIZE + ((chunk_size + 1) & ~1U);
|
||||
}
|
||||
|
||||
// Size of a chunk including header and padding.
|
||||
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
|
||||
const size_t data_size = chunk->data_.size;
|
||||
assert(data_size < MAX_CHUNK_PAYLOAD);
|
||||
return SizeWithPadding(data_size);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user