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

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
83 unsigned i, nb_planes = 0;83 unsigned i, nb_planes = 0;
84 int pixelstep[MAX_PLANES] = { 0 };84 int pixelstep[MAX_PLANES] = { 0 };
85 int full_range = 0;85 int full_range = 0;
86 int depthb = 0;
86 87
87 if (!desc || !desc->name)88 if (!desc || !desc->name)
88 return AVERROR(EINVAL);89 return AVERROR(EINVAL);
@@ -96,6 +97,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) · 7 unmodified lines
96 format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P)97 format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P)
97 full_range = 1;98 full_range = 1;
98 for (i = 0; i < desc->nb_components; i++) {99 for (i = 0; i < desc->nb_components; i++) {
100 int db;
99 c = &desc->comp[i];101 c = &desc->comp[i];
100 /* for now, only 8-16 bits formats */102 /* for now, only 8-16 bits formats */
101 if (c->depth < 8 || c->depth > 16)103 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
105 /* data must either be in the high or low bits, never middle */107 /* data must either be in the high or low bits, never middle */
106 if (c->shift && ((c->shift + c->depth) & 0x7))108 if (c->shift && ((c->shift + c->depth) & 0x7))
107 return AVERROR(ENOSYS);109 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;
108 /* strange interleaving */115 /* strange interleaving */
109 if (pixelstep[c->plane] != 0 &&116 if (pixelstep[c->plane] != 0 &&
110 pixelstep[c->plane] != c->step)117 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