diff mbox series

[FFmpeg-devel,3/6] avformat/rtsp: prefer to return EOF for incomplete read

Message ID 1638714396-23062-3-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/6] avformat/rtsp: remove redundant assignment | expand

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

Lance Wang Dec. 5, 2021, 2:26 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/rtsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marton Balint Dec. 5, 2021, 6:10 p.m. UTC | #1
On Sun, 5 Dec 2021, lance.lmwang@gmail.com wrote:

> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/rtsp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 5cffe0b..2ee2463 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1247,7 +1247,7 @@ start:
>             return AVERROR(ENOMEM);
>         if (ffurl_read_complete(rt->rtsp_hd, content, content_length) != content_length) {
>             av_freep(&content);
> -            return AVERROR(EIO);
> +            return AVERROR_EOF;

This seems wrong, ffurl_read_complete can return error as well and you are 
transforming it to AVERROR_EOF. Also if request content_length is not 
honored, then it is surely an error, so AVERROR_EOF is not the correct 
return value, because the protocol was violated.

Regards,
Marton

>         }
>         content[content_length] = '\0';
>     }
> -- 
> 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".
>
Lance Wang Dec. 6, 2021, 1:53 a.m. UTC | #2
On Sun, Dec 05, 2021 at 07:10:31PM +0100, Marton Balint wrote:
> 
> 
> On Sun, 5 Dec 2021, lance.lmwang@gmail.com wrote:
> 
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> > libavformat/rtsp.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index 5cffe0b..2ee2463 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -1247,7 +1247,7 @@ start:
> >             return AVERROR(ENOMEM);
> >         if (ffurl_read_complete(rt->rtsp_hd, content, content_length) != content_length) {
> >             av_freep(&content);
> > -            return AVERROR(EIO);
> > +            return AVERROR_EOF;
> 
> This seems wrong, ffurl_read_complete can return error as well and you are
> transforming it to AVERROR_EOF. Also if request content_length is not
> honored, then it is surely an error, so AVERROR_EOF is not the correct
> return value, because the protocol was violated.
Yes, it makes sense, I saw the previous ffurl_read_complete() in the function will return AVERROR_EOF.
I think it should return AVERROR(EIO) also.

> 
> Regards,
> Marton
> 
> >         }
> >         content[content_length] = '\0';
> >     }
> > -- 
> > 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/rtsp.c b/libavformat/rtsp.c
index 5cffe0b..2ee2463 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1247,7 +1247,7 @@  start:
             return AVERROR(ENOMEM);
         if (ffurl_read_complete(rt->rtsp_hd, content, content_length) != content_length) {
             av_freep(&content);
-            return AVERROR(EIO);
+            return AVERROR_EOF;
         }
         content[content_length] = '\0';
     }