Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
> On 28 Dec 2017, at 07:04, Michael Niedermayer wrote: > > On Mon, Nov 20, 2017 at 03:58:59PM +0800, Steven Liu wrote: >> fix ticket id: #6846 >> >> Signed-off-by: Steven Liu >> --- >> libavformat/avio.c | 10 ++ >> 1 file changed, 6 insertions(+), 4 deletions(-) > > LGTM > > thx Pushed Thanks Steven > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Rewriting code that is poorly written but fully understood is good. > Rewriting code that one doesnt understand is a sign that one is less smart > then the original author, trying to rewrite it will not make it better. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
On Mon, Nov 20, 2017 at 03:58:59PM +0800, Steven Liu wrote: > fix ticket id: #6846 > > Signed-off-by: Steven Liu > --- > libavformat/avio.c | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
On 12/27/17, 11:55 AM, "Steven Liu" wrote: >2017-11-20 15:58 GMT+08:00 Steven Liu : >> fix ticket id: #6846 >> >> Signed-off-by: Steven Liu >> --- >> libavformat/avio.c | 10 ++ >> 1 file changed, 6 insertions(+), 4 deletions(-) >> >>[…] >> int ffurl_shutdown(URLContext *h, int flags) >> { >> -if (!h->prot->url_shutdown) >> -return AVERROR(EINVAL); >> +if (!h || !h->prot || !h->prot->url_shutdown) >> +return AVERROR(ENOSYS); >> return h->prot->url_shutdown(h, flags); >> } >> >> -- >> 2.13.6 (Apple Git-96) >> >> >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >ping LGTM. In fact, I would like this change to be merged to handle some error cases in hlsenc as well. Thanks, Karthick ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
2017-11-20 15:58 GMT+08:00 Steven Liu : > fix ticket id: #6846 > > Signed-off-by: Steven Liu > --- > libavformat/avio.c | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/libavformat/avio.c b/libavformat/avio.c > index 4dc468350c..63e82872f7 100644 > --- a/libavformat/avio.c > +++ b/libavformat/avio.c > @@ -625,13 +625,15 @@ int64_t ffurl_size(URLContext *h) > > int ffurl_get_file_handle(URLContext *h) > { > -if (!h->prot->url_get_file_handle) > +if (!h || !h->prot || !h->prot->url_get_file_handle) > return -1; > return h->prot->url_get_file_handle(h); > } > > int ffurl_get_multi_file_handle(URLContext *h, int **handles, int > *numhandles) > { > +if (!h || !h->prot) > +return AVERROR(ENOSYS); > if (!h->prot->url_get_multi_file_handle) { > if (!h->prot->url_get_file_handle) > return AVERROR(ENOSYS); > @@ -647,15 +649,15 @@ int ffurl_get_multi_file_handle(URLContext *h, int > **handles, int *numhandles) > > int ffurl_get_short_seek(URLContext *h) > { > -if (!h->prot->url_get_short_seek) > +if (!h || !h->prot || !h->prot->url_get_short_seek) > return AVERROR(ENOSYS); > return h->prot->url_get_short_seek(h); > } > > int ffurl_shutdown(URLContext *h, int flags) > { > -if (!h->prot->url_shutdown) > -return AVERROR(EINVAL); > +if (!h || !h->prot || !h->prot->url_shutdown) > +return AVERROR(ENOSYS); > return h->prot->url_shutdown(h, flags); > } > > -- > 2.13.6 (Apple Git-96) > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ping ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
fix ticket id: #6846 Signed-off-by: Steven Liu --- libavformat/avio.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 4dc468350c..63e82872f7 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -625,13 +625,15 @@ int64_t ffurl_size(URLContext *h) int ffurl_get_file_handle(URLContext *h) { -if (!h->prot->url_get_file_handle) +if (!h || !h->prot || !h->prot->url_get_file_handle) return -1; return h->prot->url_get_file_handle(h); } int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) { +if (!h || !h->prot) +return AVERROR(ENOSYS); if (!h->prot->url_get_multi_file_handle) { if (!h->prot->url_get_file_handle) return AVERROR(ENOSYS); @@ -647,15 +649,15 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) int ffurl_get_short_seek(URLContext *h) { -if (!h->prot->url_get_short_seek) +if (!h || !h->prot || !h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); } int ffurl_shutdown(URLContext *h, int flags) { -if (!h->prot->url_shutdown) -return AVERROR(EINVAL); +if (!h || !h->prot || !h->prot->url_shutdown) +return AVERROR(ENOSYS); return h->prot->url_shutdown(h, flags); } -- 2.13.6 (Apple Git-96) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
On 2017/11/20 15:43, Jun Zhao wrote: > > On 2017/11/20 15:35, 刘歧 wrote: >>> 在 2017年11月20日,15:23,Jun Zhao 写道: >>> >>> >>> >>> On 2017/11/20 14:45, Steven Liu wrote: fix ticket id: #6846 Signed-off-by: Steven Liu --- libavformat/avio.c | 8 1 file changed, 8 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index 4dc468350c..e719326660 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) int ffurl_get_file_handle(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_file_handle) >>> I think (!h && !h->prot && !h->prot->url_get_file_handle) more better >>> than this >> maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it? > No, I means > if (!h && !h->prot && !h->prot->url_get_file_handle) > Do somthing > else > return error; Made a mistake in the comments, shame :( you are right. return -1; return h->prot->url_get_file_handle(h); @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_multi_file_handle) { if (!h->prot->url_get_file_handle) return AVERROR(ENOSYS); @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) int ffurl_get_short_seek(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) int ffurl_shutdown(URLContext *h, int flags) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_shutdown) return AVERROR(EINVAL); return h->prot->url_shutdown(h, flags); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
> 在 2017年11月20日,15:43,Jun Zhao 写道: > > > > On 2017/11/20 15:35, 刘歧 wrote: >> >>> 在 2017年11月20日,15:23,Jun Zhao 写道: >>> >>> >>> >>> On 2017/11/20 14:45, Steven Liu wrote: fix ticket id: #6846 Signed-off-by: Steven Liu --- libavformat/avio.c | 8 1 file changed, 8 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index 4dc468350c..e719326660 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) int ffurl_get_file_handle(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_file_handle) >>> I think (!h && !h->prot && !h->prot->url_get_file_handle) more better >>> than this >> maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it? > No, I means > if (!h && !h->prot && !h->prot->url_get_file_handle) > Do somthing will segmentation failed if !h is true, that is when h = NULL, and then get h->prot or h->prot->url_get_file_handle will in EXC_BAD_ACCESS. So i this the better is (!h || !h->port || !h->prot->url_get_file_handle) return error. > else > return error; > return -1; return h->prot->url_get_file_handle(h); @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_multi_file_handle) { if (!h->prot->url_get_file_handle) return AVERROR(ENOSYS); @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) int ffurl_get_short_seek(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) int ffurl_shutdown(URLContext *h, int flags) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_shutdown) return AVERROR(EINVAL); return h->prot->url_shutdown(h, flags); > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
On 2017/11/20 15:35, 刘歧 wrote: > >> 在 2017年11月20日,15:23,Jun Zhao 写道: >> >> >> >> On 2017/11/20 14:45, Steven Liu wrote: >>> fix ticket id: #6846 >>> >>> Signed-off-by: Steven Liu >>> --- >>> libavformat/avio.c | 8 >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/libavformat/avio.c b/libavformat/avio.c >>> index 4dc468350c..e719326660 100644 >>> --- a/libavformat/avio.c >>> +++ b/libavformat/avio.c >>> @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) >>> >>> int ffurl_get_file_handle(URLContext *h) >>> { >>> +if (!h) >>> +return AVERROR(EINVAL); >>> if (!h->prot->url_get_file_handle) >> I think (!h && !h->prot && !h->prot->url_get_file_handle) more better >> than this > maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it? No, I means if (!h && !h->prot && !h->prot->url_get_file_handle) Do somthing else return error; >>> return -1; >>> return h->prot->url_get_file_handle(h); >>> @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) >>> >>> int ffurl_get_multi_file_handle(URLContext *h, int **handles, int >>> *numhandles) >>> { >>> +if (!h) >>> +return AVERROR(EINVAL); >>> if (!h->prot->url_get_multi_file_handle) { >>> if (!h->prot->url_get_file_handle) >>> return AVERROR(ENOSYS); >>> @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int >>> **handles, int *numhandles) >>> >>> int ffurl_get_short_seek(URLContext *h) >>> { >>> +if (!h) >>> +return AVERROR(EINVAL); >>> if (!h->prot->url_get_short_seek) >>> return AVERROR(ENOSYS); >>> return h->prot->url_get_short_seek(h); >>> @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) >>> >>> int ffurl_shutdown(URLContext *h, int flags) >>> { >>> +if (!h) >>> +return AVERROR(EINVAL); >>> if (!h->prot->url_shutdown) >>> return AVERROR(EINVAL); >>> return h->prot->url_shutdown(h, flags); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
> 在 2017年11月20日,15:23,Jun Zhao 写道: > > > > On 2017/11/20 14:45, Steven Liu wrote: >> fix ticket id: #6846 >> >> Signed-off-by: Steven Liu >> --- >> libavformat/avio.c | 8 >> 1 file changed, 8 insertions(+) >> >> diff --git a/libavformat/avio.c b/libavformat/avio.c >> index 4dc468350c..e719326660 100644 >> --- a/libavformat/avio.c >> +++ b/libavformat/avio.c >> @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) >> >> int ffurl_get_file_handle(URLContext *h) >> { >> +if (!h) >> +return AVERROR(EINVAL); >> if (!h->prot->url_get_file_handle) > I think (!h && !h->prot && !h->prot->url_get_file_handle) more better > than this maybe you mean (!h || !h->port || !h->prot->url_get_file_handle) , is it? > >> return -1; >> return h->prot->url_get_file_handle(h); >> @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) >> >> int ffurl_get_multi_file_handle(URLContext *h, int **handles, int >> *numhandles) >> { >> +if (!h) >> +return AVERROR(EINVAL); >> if (!h->prot->url_get_multi_file_handle) { >> if (!h->prot->url_get_file_handle) >> return AVERROR(ENOSYS); >> @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int >> **handles, int *numhandles) >> >> int ffurl_get_short_seek(URLContext *h) >> { >> +if (!h) >> +return AVERROR(EINVAL); >> if (!h->prot->url_get_short_seek) >> return AVERROR(ENOSYS); >> return h->prot->url_get_short_seek(h); >> @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) >> >> int ffurl_shutdown(URLContext *h, int flags) >> { >> +if (!h) >> +return AVERROR(EINVAL); >> if (!h->prot->url_shutdown) >> return AVERROR(EINVAL); >> return h->prot->url_shutdown(h, flags); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
On 2017/11/20 14:45, Steven Liu wrote: > fix ticket id: #6846 > > Signed-off-by: Steven Liu > --- > libavformat/avio.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/libavformat/avio.c b/libavformat/avio.c > index 4dc468350c..e719326660 100644 > --- a/libavformat/avio.c > +++ b/libavformat/avio.c > @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) > > int ffurl_get_file_handle(URLContext *h) > { > +if (!h) > +return AVERROR(EINVAL); > if (!h->prot->url_get_file_handle) I think (!h && !h->prot && !h->prot->url_get_file_handle) more better than this > return -1; > return h->prot->url_get_file_handle(h); > @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) > > int ffurl_get_multi_file_handle(URLContext *h, int **handles, int > *numhandles) > { > +if (!h) > +return AVERROR(EINVAL); > if (!h->prot->url_get_multi_file_handle) { > if (!h->prot->url_get_file_handle) > return AVERROR(ENOSYS); > @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int > **handles, int *numhandles) > > int ffurl_get_short_seek(URLContext *h) > { > +if (!h) > +return AVERROR(EINVAL); > if (!h->prot->url_get_short_seek) > return AVERROR(ENOSYS); > return h->prot->url_get_short_seek(h); > @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) > > int ffurl_shutdown(URLContext *h, int flags) > { > +if (!h) > +return AVERROR(EINVAL); > if (!h->prot->url_shutdown) > return AVERROR(EINVAL); > return h->prot->url_shutdown(h, flags); ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
fix ticket id: #6846 Signed-off-by: Steven Liu --- libavformat/avio.c | 8 1 file changed, 8 insertions(+) diff --git a/libavformat/avio.c b/libavformat/avio.c index 4dc468350c..e719326660 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h) int ffurl_get_file_handle(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_file_handle) return -1; return h->prot->url_get_file_handle(h); @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h) int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_multi_file_handle) { if (!h->prot->url_get_file_handle) return AVERROR(ENOSYS); @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles) int ffurl_get_short_seek(URLContext *h) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h) int ffurl_shutdown(URLContext *h, int flags) { +if (!h) +return AVERROR(EINVAL); if (!h->prot->url_shutdown) return AVERROR(EINVAL); return h->prot->url_shutdown(h, flags); -- 2.13.6 (Apple Git-96) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel