History

avcodec/exr: Dont access outside xsize/ysize

Fixes: out of array access Fixes: BIGSLEEP-436510316/dwa_uncompress_write.exr

Michael Niedermayer committed 1 year ago

Commit f45da791 parent 0d9c0031 file · +6 −4Browse files

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

Unified · Split

libavcodec/exr.c+6−4
@@ -1127,6 +1127,8 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 1126 unmodified lines
11271127 float *yb = td->block[0];
11281128 float *ub = td->block[1];
11291129 float *vb = td->block[2];
1130+ int bw = FFMIN(8, td->xsize - x);
1131+ int bh = FFMIN(8, td->ysize - y);
11301132
11311133 memset(td->block, 0, sizeof(td->block));
11321134
@@ -1151,8 +1153,8 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 18 unmodified lines
11511153 uint16_t *ro = ((uint16_t *)td->uncompressed_data) +
11521154 y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x;
11531155
1154− for (int yy = 0; yy < 8; yy++) {
1155− for (int xx = 0; xx < 8; xx++) {
1156+ for (int yy = 0; yy < bh; yy++) {
1157+ for (int xx = 0; xx < bw; xx++) {
11561158 const int idx = xx + yy * 8;
11571159 float b, g, r;
11581160
@@ -1175,8 +1177,8 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse · 16 unmodified lines
11751177 float *ro = ((float *)td->uncompressed_data) +
11761178 y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x;
11771179
1178− for (int yy = 0; yy < 8; yy++) {
1179− for (int xx = 0; xx < 8; xx++) {
1180+ for (int yy = 0; yy < bh; yy++) {
1181+ for (int xx = 0; xx < bw; xx++) {
11801182 const int idx = xx + yy * 8;
11811183
11821184 convert(yb[idx], ub[idx], vb[idx], &bo[xx], &go[xx], &ro[xx]);

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