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
1758 GetByteContext stripdata;1758 GetByteContext stripdata;
1759 int retry_for_subifd, retry_for_page;1759 int retry_for_subifd, retry_for_page;
1760 int is_dng;1760 int is_dng;
1761 int has_tile_bits, has_strip_bits;
1761 1762
1762 bytestream2_init(&s->gb, avpkt->data, avpkt->size);1763 bytestream2_init(&s->gb, avpkt->data, avpkt->size);
1763 1764
@@ -1885,6 +1886,14 @@ again: · 121 unmodified lines
1885 return AVERROR_INVALIDDATA;1886 return AVERROR_INVALIDDATA;
1886 }1887 }
1887 1888
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
1888 /* now we have the data and may start decoding */1897 /* now we have the data and may start decoding */
1889 if ((ret = init_image(s, &frame)) < 0)1898 if ((ret = init_image(s, &frame)) < 0)
1890 return ret;1899 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