Opened 3 years ago
#9181 new defect
avio_skip() does not return EOF if offset is large
| Reported by: | Guangyu Sun | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avformat |
| Version: | git-master | Keywords: | avio_skip, file |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
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
Note:
See TracTickets
for help on using tickets.


