mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-12 23:12:52 +01:00
Disallow re-use of same transformation.
Limit the overall number of transformations to 4 and disallow any duplicate transform for decoding an image. Change-Id: Ic4b0ecd553db96702e117fd073617237d95e45c0
This commit is contained in:
parent
98ec717f1e
commit
9fc64edc21
@ -707,15 +707,22 @@ static int ExpandColorMap(int num_colors, VP8LTransform* const transform) {
|
|||||||
|
|
||||||
static int ReadTransform(int* const xsize, int const* ysize,
|
static int ReadTransform(int* const xsize, int const* ysize,
|
||||||
VP8LDecoder* const dec) {
|
VP8LDecoder* const dec) {
|
||||||
|
int i;
|
||||||
int ok = 1;
|
int ok = 1;
|
||||||
VP8LBitReader* const br = &dec->br_;
|
VP8LBitReader* const br = &dec->br_;
|
||||||
VP8LTransform* transform = &dec->transforms_[dec->next_transform_];
|
VP8LTransform* transform = &dec->transforms_[dec->next_transform_];
|
||||||
const VP8LImageTransformType type =
|
const VP8LImageTransformType type =
|
||||||
(VP8LImageTransformType)VP8LReadBits(br, 2);
|
(VP8LImageTransformType)VP8LReadBits(br, 2);
|
||||||
|
|
||||||
if (dec->next_transform_ == NUM_TRANSFORMS) {
|
// Each transform type can only be present once in the stream.
|
||||||
return 0;
|
// TODO(later): use a bit set to mark already-used transforms.
|
||||||
|
for (i = 0; i < dec->next_transform_; ++i) {
|
||||||
|
if (dec->transforms_[i].type_ == type) {
|
||||||
|
return 0; // Already there, let's not accept the second same transform.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
assert(dec->next_transform_ < NUM_TRANSFORMS);
|
||||||
|
|
||||||
transform->type_ = type;
|
transform->type_ = type;
|
||||||
transform->xsize_ = *xsize;
|
transform->xsize_ = *xsize;
|
||||||
transform->ysize_ = *ysize;
|
transform->ysize_ = *ysize;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NUM_TRANSFORMS 8
|
#define NUM_TRANSFORMS 4
|
||||||
#define HUFFMAN_CODES_PER_META_CODE 5
|
#define HUFFMAN_CODES_PER_META_CODE 5
|
||||||
#define ARGB_BLACK 0xff000000
|
#define ARGB_BLACK 0xff000000
|
||||||
#define NUM_LITERAL_CODES 256
|
#define NUM_LITERAL_CODES 256
|
||||||
|
Loading…
x
Reference in New Issue
Block a user