History

lavfi/drawutils: ensure we don't allow mixed-byte-depth formats

These could be hazardous because of FFDrawColor's union

rcombs committed 4 years ago

Commit f00079b1 parent e24b71a1 file · +7 −0Browse files

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

Unified · Split

libavfilter/drawutils.c+7−0
@@ -83,6 +83,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) · 82 unmodified lines
8383 unsigned i, nb_planes = 0;
8484 int pixelstep[MAX_PLANES] = { 0 };
8585 int full_range = 0;
86+ int depthb = 0;
8687
8788 if (!desc || !desc->name)
8889 return AVERROR(EINVAL);
@@ -96,6 +97,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) · 7 unmodified lines
9697 format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P)
9798 full_range = 1;
9899 for (i = 0; i < desc->nb_components; i++) {
100+ int db;
99101 c = &desc->comp[i];
100102 /* for now, only 8-16 bits formats */
101103 if (c->depth < 8 || c->depth > 16)
@@ -105,6 +107,11 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) · 3 unmodified lines
105107 /* data must either be in the high or low bits, never middle */
106108 if (c->shift && ((c->shift + c->depth) & 0x7))
107109 return AVERROR(ENOSYS);
110+ /* mixed >8 and <=8 depth */
111+ db = (c->depth + 7) / 8;
112+ if (depthb && (depthb != db))
113+ return AVERROR(ENOSYS);
114+ depthb = db;
108115 /* strange interleaving */
109116 if (pixelstep[c->plane] != 0 &&
110117 pixelstep[c->plane] != c->step)

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