History

avformat/dhav: Fix incorrect non-DHAV chunk skipping logic

DAV files may contain a variable length padding in between chunks filled with 0xff bytes. The current skipping logic is incorrect as it may skip over DHAV chunks not appearing sequentially in the file. We now look for the 'DHAV' tag using a byte-by-byte search in order to handle such situations. Also the dhav->last_good_pos field will not be updated while skipping unrecognized data.

Idan Freiberg committed 5 years ago

Commit a6912e51 parent f6477ac1 file · +3 −12Browse files

Unified · Split

libavformat/dhav.c+3−12
@@ -173,18 +173,9 @@ static int read_chunk(AVFormatContext *s) · 172 unmodified lines
173173 if (avio_feof(s->pb))
174174 return AVERROR_EOF;
175175
176− if (avio_rl32(s->pb) != MKTAG('D','H','A','V') && dhav->last_good_pos < INT64_MAX - 0x8000) {
177− dhav->last_good_pos += 0x8000;
178− avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
179−
180− while (avio_rl32(s->pb) != MKTAG('D','H','A','V')) {
181− if (avio_feof(s->pb) || dhav->last_good_pos >= INT64_MAX - 0x8000)
182− return AVERROR_EOF;
183− dhav->last_good_pos += 0x8000;
184− ret = avio_skip(s->pb, 0x8000 - 4);
185− if (ret < 0)
186− return ret;
187− }
176+ while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' || avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
177+ if (avio_feof(s->pb))
178+ return AVERROR_EOF;
188179 }
189180
190181 start = avio_tell(s->pb) - 4;

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