Opened 10 years ago
Closed 10 years ago
#4152 closed defect (fixed)
jacosub: deadlock with fuzzed file
Reported by: | tholin | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avformat |
Version: | git-master | Keywords: | jacosub deadlock |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
I found a deadlock in mpv with fuzzed file. The problem appears to be in ffmpeg so I report it here directly.
jacosub_read_header() in ffmpeg/libavformat/jacosubdec.c:156 will continuesly call ff_get_line() as long as eof isn't reached.
When ff_get_line() reads a \r it tries to remove the following \n if it exists. If eof is triggered after the first read the next read will return 0 which is not a \n and the stream is rewound one byte and the eof flag is cleared. This puts the stream in the same state as before and jacosub_read_header() loops indefinitely.
int ff_get_line(AVIOContext *s, char *buf, int maxlen) ffmpeg/libavformat/aviobuf.c:669 { int i = 0; char c; do { c = avio_r8(s); <--- last byte read in stream (\r) if (c && i < maxlen-1) buf[i++] = c; } while (c != '\n' && c != '\r' && c); if (c == '\r' && avio_r8(s) != '\n') <--- trigger EOF and returns 0 avio_skip(s, -1); <--- rewinds and clears eof_reached flag buf[i] = 0; return i; }
Here is a base64 encoded example file CQoKCgtAMUAxMwoKDQ0NDS4NDQ0LCwsLC6FcgAGhXIABDQ0NDQ0NDQ0NDYABDQ0fDQkNDQ0NDQ0NDQsNDQ0N
Attachments (1)
Change History (3)
by , 10 years ago
Attachment: | jacosub.jss added |
---|
comment:1 by , 10 years ago
Keywords: | jacosub deadlock added |
---|---|
Priority: | normal → important |
Reproduced by developer: | set |
Status: | new → open |
comment:2 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | open → closed |
For future tickets: Please understand that while an analysis is helpful, never replace the actual report with an analysis of the bug, always provide the failing command line together with the complete, uncut console output. And please do not compress, encrypt or encode the input sample, simply attach it.