[FFmpeg-trac] #9181(avformat:new): avio_skip() does not return EOF if offset is large
FFmpeg
trac at avcodec.org
Mon Apr 12 23:26:41 EEST 2021
#9181: avio_skip() does not return EOF if offset is large
-------------------------------------+-------------------------------------
Reporter: gsun | Type: defect
Status: new | Priority: normal
Component: avformat | Version: git-
Keywords: | master
avio_skip,file | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary of the bug:
When calling
{{{
int64_t avio_skip(AVIOContext *s, int64_t offset)
}}}
on an avio-opened file, EOF is returned if skipped beyond the end of the
file.
But if offset is greater than the internal buffer size (default is
IO_BUFFER_SIZE 32768), EOF will not be returned.
How to reproduce:
Write a program with libavformat:
{{{
#include <libavformat/avio.h>
int main(int argc, char *argv[])
{
if (argc < 3)
return 1;
int64_t offset = atoll(argv[1]);
AVIOContext *avio_ctx = NULL;
avio_open2(&avio_ctx, argv[2], AVIO_FLAG_READ, NULL, NULL);
int64_t res = avio_skip(avio_ctx, offset);
printf("res %"PRId64" %s\n", res, av_err2str(res));
return 0;
}
}}}
Compile the program to a binary with name "test" and run:
{{{
# seek with an 8-byte file
$ echo 12345678 > testfile
$ ls -l testfile
-rw-r--r-- 1 gsun staff 8 Mar 29 09:06 testfile
$ ./test 8 testfile
res 8 Error number 8 occurred
$ ./test 9 testfile
res -541478725 End of file
$ ./test 32768 testfile
res -541478725 End of file
$ ./test 32769 testfile
res 32769 Error number 32769 occurred
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9181>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list