Opened 4 years ago

Closed 4 years ago

#2537 closed defect (fixed)

ffurl_read_complete returns incorrect value

Reported by: jyavenard Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
This bug report is about the use of the avio's API amd ffurl_read_complete

according to the documentation, ffurl_read_complete:

Read as many bytes as possible (up to size), calling the read function multiple times if necessary.

This makes special short-read handling in applications unnecessary, if the return value is < size then it is certain there was either an error or the end of file was reached.

Definition at line 310 of file avio.c.

The issue is actually in retry_transfer_wrapper in avio.c.

If you try to read n-bytes of data using ffurl_read_complete when the current position in the file is less than n-bytes from the end.
ffurl_read_complete will return AVERROR_EOF instead of the number of bytes actually read (and here the number of bytes returned would be less than the number of bytes asked).

Expected behaviour:
ffurl_read_complete when encountering an end of file, should return the number of bytes actually read, and set eof flags accordingly

Background information.
The issue was found trying to play file in #2513
and reading the MOOV data. The MOOV table is located at the end of the file. MythTV seeks data from the file using ffurl_read_complete ; it would sometimes fail because we are enable to read the data close to the end of the file.

Change History (2)

comment:1 Changed 4 years ago by jyavenard

  • Component changed from undetermined to avformat
  • Version changed from unspecified to git-master

comment:2 Changed 4 years ago by michael

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.