diff mbox series

[FFmpeg-devel,8/8] avformat/mpegts: return proper error codes

Message ID 1634216942-20329-8-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/8] avfilter/af_replaygain: use fabsf() instead of fabs()
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Limin Wang Oct. 14, 2021, 1:09 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/mpegts.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Marton Balint Oct. 14, 2021, 7:46 p.m. UTC | #1
On Thu, 14 Oct 2021, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/mpegts.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

No, parse_stream_identifier_desc intentionally returns -1 for error, check 
how the code works which uses the function.

Regards,
Marton

>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 774964d..3157e3a 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2270,22 +2270,22 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
>
>     desc_list_len = get16(pp, p_end);
>     if (desc_list_len < 0)
> -        return -1;
> +        return AVERROR_INVALIDDATA;
>     desc_list_len &= 0xfff;
>     desc_list_end  = p + desc_list_len;
>     if (desc_list_end > p_end)
> -        return -1;
> +        return AVERROR_INVALIDDATA;
>
>     while (1) {
>         desc_tag = get8(pp, desc_list_end);
>         if (desc_tag < 0)
> -            return -1;
> +            return AVERROR_INVALIDDATA;
>         desc_len = get8(pp, desc_list_end);
>         if (desc_len < 0)
> -            return -1;
> +            return AVERROR_INVALIDDATA;
>         desc_end = *pp + desc_len;
>         if (desc_end > desc_list_end)
> -            return -1;
> +            return AVERROR_INVALIDDATA;
>
>         if (desc_tag == 0x52) {
>             return get8(pp, desc_end);
> @@ -2293,7 +2293,7 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
>         *pp = desc_end;
>     }
>
> -    return -1;
> +    return AVERROR_INVALIDDATA;
> }
>
> static int is_pes_stream(int stream_type, uint32_t prog_reg_desc)
> -- 
> 1.8.3.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Limin Wang Oct. 14, 2021, 10:54 p.m. UTC | #2
On Thu, Oct 14, 2021 at 09:46:37PM +0200, Marton Balint wrote:
> 
> 
> On Thu, 14 Oct 2021, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/mpegts.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> No, parse_stream_identifier_desc intentionally returns -1 for error, check
> how the code works which uses the function.

Sorry, please ignore the patch. Anyway, it's error, but the current ignore it
with a hacky.

> 
> Regards,
> Marton
> 
> > 
> > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> > index 774964d..3157e3a 100644
> > --- a/libavformat/mpegts.c
> > +++ b/libavformat/mpegts.c
> > @@ -2270,22 +2270,22 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
> > 
> >     desc_list_len = get16(pp, p_end);
> >     if (desc_list_len < 0)
> > -        return -1;
> > +        return AVERROR_INVALIDDATA;
> >     desc_list_len &= 0xfff;
> >     desc_list_end  = p + desc_list_len;
> >     if (desc_list_end > p_end)
> > -        return -1;
> > +        return AVERROR_INVALIDDATA;
> > 
> >     while (1) {
> >         desc_tag = get8(pp, desc_list_end);
> >         if (desc_tag < 0)
> > -            return -1;
> > +            return AVERROR_INVALIDDATA;
> >         desc_len = get8(pp, desc_list_end);
> >         if (desc_len < 0)
> > -            return -1;
> > +            return AVERROR_INVALIDDATA;
> >         desc_end = *pp + desc_len;
> >         if (desc_end > desc_list_end)
> > -            return -1;
> > +            return AVERROR_INVALIDDATA;
> > 
> >         if (desc_tag == 0x52) {
> >             return get8(pp, desc_end);
> > @@ -2293,7 +2293,7 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
> >         *pp = desc_end;
> >     }
> > 
> > -    return -1;
> > +    return AVERROR_INVALIDDATA;
> > }
> > 
> > static int is_pes_stream(int stream_type, uint32_t prog_reg_desc)
> > -- 
> > 1.8.3.1
> > 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 774964d..3157e3a 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2270,22 +2270,22 @@  static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
 
     desc_list_len = get16(pp, p_end);
     if (desc_list_len < 0)
-        return -1;
+        return AVERROR_INVALIDDATA;
     desc_list_len &= 0xfff;
     desc_list_end  = p + desc_list_len;
     if (desc_list_end > p_end)
-        return -1;
+        return AVERROR_INVALIDDATA;
 
     while (1) {
         desc_tag = get8(pp, desc_list_end);
         if (desc_tag < 0)
-            return -1;
+            return AVERROR_INVALIDDATA;
         desc_len = get8(pp, desc_list_end);
         if (desc_len < 0)
-            return -1;
+            return AVERROR_INVALIDDATA;
         desc_end = *pp + desc_len;
         if (desc_end > desc_list_end)
-            return -1;
+            return AVERROR_INVALIDDATA;
 
         if (desc_tag == 0x52) {
             return get8(pp, desc_end);
@@ -2293,7 +2293,7 @@  static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
         *pp = desc_end;
     }
 
-    return -1;
+    return AVERROR_INVALIDDATA;
 }
 
 static int is_pes_stream(int stream_type, uint32_t prog_reg_desc)