asfdec: fix reading files larger than 2GB

Message ID 20170224000509.14109-1-stebbins@jetheaddev.com
State New
Headers show

Commit Message

John Stebbins Feb. 24, 2017, 12:05 a.m.
avio_skip returns file position and overflows int
---
 libavformat/asfdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Luca Barbato Feb. 24, 2017, 3:50 a.m. | #1
On 24/02/2017 01:05, John Stebbins wrote:
> avio_skip returns file position and overflows int
> ---
>  libavformat/asfdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 34730b2..10d3396 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -976,7 +976,8 @@ static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
>      uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s
>      uint32_t pkt_num, nb_entries;
>      int32_t prev_pkt_num = -1;
> -    int i, ret;
> +    int i;
> +    int64_t ret;
>      uint64_t size = avio_rl64(pb);
>  
>      // simple index objects should be ordered by stream number, this loop tries to find
> 

Sounds good, I hadn't look at the code but maybe it might be clearer
using a second variable.

lu
John Stebbins Feb. 24, 2017, 3:22 p.m. | #2
On 02/23/2017 08:50 PM, Luca Barbato wrote:
> On 24/02/2017 01:05, John Stebbins wrote:
>> avio_skip returns file position and overflows int
>> ---
>>  libavformat/asfdec.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
>> index 34730b2..10d3396 100644
>> --- a/libavformat/asfdec.c
>> +++ b/libavformat/asfdec.c
>> @@ -976,7 +976,8 @@ static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
>>      uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s
>>      uint32_t pkt_num, nb_entries;
>>      int32_t prev_pkt_num = -1;
>> -    int i, ret;
>> +    int i;
>> +    int64_t ret;
>>      uint64_t size = avio_rl64(pb);
>>  
>>      // simple index objects should be ordered by stream number, this loop tries to find
>>
> Sounds good, I hadn't look at the code but maybe it might be clearer
> using a second variable.
>
>

ret is only used for this one instance of avio_skip and nowhere else in the function.  But would you prefer I rename it
to something like "offset" so that the code documents itself better?
Luca Barbato Feb. 24, 2017, 5:18 p.m. | #3
On 24/02/2017 16:22, John Stebbins wrote:
> ret is only used for this one instance of avio_skip and nowhere else in the function.  But would you prefer I rename it
> to something like "offset" so that the code documents itself better?

Sounds good to me :)

lu

Patch

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 34730b2..10d3396 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -976,7 +976,8 @@  static int asf_read_simple_index(AVFormatContext *s, const GUIDParseTable *g)
     uint64_t interval; // index entry time interval in 100 ns units, usually it's 1s
     uint32_t pkt_num, nb_entries;
     int32_t prev_pkt_num = -1;
-    int i, ret;
+    int i;
+    int64_t ret;
     uint64_t size = avio_rl64(pb);
 
     // simple index objects should be ordered by stream number, this loop tries to find