History

avcodec/ffv1enc_template: Fix remaining space check

Fixes: Assertion sc->slice_coding_mode == 0 failed at libavcodec/ffv1enc.c:1667 Fixes: 408838118/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-6493138204295168

Michael Niedermayer committed 1 year ago

Commit 67040771 parent 27c5e4b1 file · +15 −9Browse files

Unified · Split

libavcodec/ffv1enc_template.c+15−9
@@ -38,19 +38,13 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, · 37 unmodified lines
38 if (bits == 0)38 if (bits == 0)
39 return 0;39 return 0;
40 40
41 if (ac != AC_GOLOMB_RICE) {41 if (sc->slice_coding_mode == 1) {
42 if (c->bytestream_end - c->bytestream < w * 35) {42 av_assert0(ac != AC_GOLOMB_RICE);
43 if (c->bytestream_end - c->bytestream < (w * bits + 7LL)>>3) {
43 av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n");44 av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n");
44 return AVERROR_INVALIDDATA;45 return AVERROR_INVALIDDATA;
45 }46 }
46 } else {
47 if (put_bytes_left(&sc->pb, 0) < w * 4) {
48 av_log(logctx, AV_LOG_ERROR, "encoded Golomb Rice frame too large\n");
49 return AVERROR_INVALIDDATA;
50 }
51 }
52 47
53 if (sc->slice_coding_mode == 1) {
54 for (x = 0; x < w; x++) {48 for (x = 0; x < w; x++) {
55 int i;49 int i;
56 int v = sample[0][x];50 int v = sample[0][x];
@@ -62,6 +56,18 @@ RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc, · 5 unmodified lines
62 return 0;56 return 0;
63 }57 }
64 58
59 if (ac != AC_GOLOMB_RICE) {
60 if (c->bytestream_end - c->bytestream < w * 35) {
61 av_log(logctx, AV_LOG_ERROR, "encoded Range Coder frame too large\n");
62 return AVERROR_INVALIDDATA;
63 }
64 } else {
65 if (put_bytes_left(&sc->pb, 0) < w * 4) {
66 av_log(logctx, AV_LOG_ERROR, "encoded Golomb Rice frame too large\n");
67 return AVERROR_INVALIDDATA;
68 }
69 }
70
65 for (x = 0; x < w; x++) {71 for (x = 0; x < w; x++) {
66 int diff, context;72 int diff, context;
67 73

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