[FFmpeg-devel,2/3] avformat/vivo: improve probing of some files

Submitted by Paul B Mahol on April 4, 2018, 2:09 p.m.

Details

Message ID 20180404140937.10331-2-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol April 4, 2018, 2:09 p.m.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/vivo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer April 4, 2018, 8:39 p.m.
On Wed, Apr 04, 2018 at 04:09:36PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/vivo.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/vivo.c b/libavformat/vivo.c
> index c9e9c37f37..6a88a09a01 100644
> --- a/libavformat/vivo.c
> +++ b/libavformat/vivo.c
> @@ -59,9 +59,10 @@ static int vivo_probe(AVProbeData *p)
>      if (c & 0x80 || length > 1024 || length < 21)
>          return 0;
>  
> -    if (memcmp(buf, "\r\nVersion:Vivo/", 15))
> +    buf += 2;
> +    if (memcmp(buf, "Version:Vivo/", 13))
>          return 0;

what is in the 2 bytes that are not checked anymore ?

[...]
Paul B Mahol April 4, 2018, 8:40 p.m.
On 4/4/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Wed, Apr 04, 2018 at 04:09:36PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>> ---
>>  libavformat/vivo.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/vivo.c b/libavformat/vivo.c
>> index c9e9c37f37..6a88a09a01 100644
>> --- a/libavformat/vivo.c
>> +++ b/libavformat/vivo.c
>> @@ -59,9 +59,10 @@ static int vivo_probe(AVProbeData *p)
>>      if (c & 0x80 || length > 1024 || length < 21)
>>          return 0;
>>
>> -    if (memcmp(buf, "\r\nVersion:Vivo/", 15))
>> +    buf += 2;
>> +    if (memcmp(buf, "Version:Vivo/", 13))
>>          return 0;
>
> what is in the 2 bytes that are not checked anymore ?

Irrelevant bytes.
Michael Niedermayer April 5, 2018, 12:57 a.m.
On Wed, Apr 04, 2018 at 10:40:39PM +0200, Paul B Mahol wrote:
> On 4/4/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > On Wed, Apr 04, 2018 at 04:09:36PM +0200, Paul B Mahol wrote:
> >> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> >> ---
> >>  libavformat/vivo.c | 5 +++--
> >>  1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/vivo.c b/libavformat/vivo.c
> >> index c9e9c37f37..6a88a09a01 100644
> >> --- a/libavformat/vivo.c
> >> +++ b/libavformat/vivo.c
> >> @@ -59,9 +59,10 @@ static int vivo_probe(AVProbeData *p)
> >>      if (c & 0x80 || length > 1024 || length < 21)
> >>          return 0;
> >>
> >> -    if (memcmp(buf, "\r\nVersion:Vivo/", 15))
> >> +    buf += 2;
> >> +    if (memcmp(buf, "Version:Vivo/", 13))
> >>          return 0;
> >
> > what is in the 2 bytes that are not checked anymore ?
> 
> Irrelevant bytes.

of course, but i was just wondering if this would not be more robust
to skip "n" bytes of whitespace.
That is unless you know it will always be 2 or there are cases 
where its not whitespace


[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/vivo.c b/libavformat/vivo.c
index c9e9c37f37..6a88a09a01 100644
--- a/libavformat/vivo.c
+++ b/libavformat/vivo.c
@@ -59,9 +59,10 @@  static int vivo_probe(AVProbeData *p)
     if (c & 0x80 || length > 1024 || length < 21)
         return 0;
 
-    if (memcmp(buf, "\r\nVersion:Vivo/", 15))
+    buf += 2;
+    if (memcmp(buf, "Version:Vivo/", 13))
         return 0;
-    buf += 15;
+    buf += 13;
 
     if (*buf < '0' || *buf > '2')
         return 0;