History

avcodec/tiff: Check for Tiled and Stripped TIFFs

TIFF 6 spec: "Do not use both strip-oriented and tile-oriented fields in the same TIFF file." Fixes: null pointer use, crash Fixes: crash-762680f9d1b27f9b9085e12887ad44893fb2b020

Michael Niedermayer committed 6 years ago

Commit 70faa9f1 parent 49459ac1 file · +9 −0Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/tiff.c+9−0
@@ -1758,6 +1758,7 @@ static int decode_frame(AVCodecContext *avctx, · 1757 unmodified lines
17581758 GetByteContext stripdata;
17591759 int retry_for_subifd, retry_for_page;
17601760 int is_dng;
1761+ int has_tile_bits, has_strip_bits;
17611762
17621763 bytestream2_init(&s->gb, avpkt->data, avpkt->size);
17631764
@@ -1885,6 +1886,14 @@ again: · 121 unmodified lines
18851886 return AVERROR_INVALIDDATA;
18861887 }
18871888
1889+ has_tile_bits = s->is_tiled || s->tile_byte_counts_offset || s->tile_offsets_offset || s->tile_width || s->tile_length || s->tile_count;
1890+ has_strip_bits = s->strippos || s->strips || s->stripoff || s->rps || s->sot || s->sstype || s->stripsize || s->stripsizesoff;
1891+
1892+ if (has_tile_bits && has_strip_bits) {
1893+ av_log(avctx, AV_LOG_ERROR, "Tiled TIFF is not allowed to strip\n");
1894+ return AVERROR_INVALIDDATA;
1895+ }
1896+
18881897 /* now we have the data and may start decoding */
18891898 if ((ret = init_image(s, &frame)) < 0)
18901899 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t