diff mbox

[FFmpeg-devel,1/8] avformat/avio: check for null context to avoid uninitialized pointer access

Message ID 1522386489-16171-1-git-send-email-vdixit@akamai.com
State New
Headers show

Commit Message

Dixit, Vishwanath March 30, 2018, 5:08 a.m. UTC
From: Vishwanath Dixit <vdixit@akamai.com>

---
 libavformat/avio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

wm4 March 30, 2018, 1:16 p.m. UTC | #1
On Fri, 30 Mar 2018 10:38:09 +0530
vdixit@akamai.com wrote:

> From: Vishwanath Dixit <vdixit@akamai.com>
> 
> ---
>  libavformat/avio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 63e8287..18e58ae 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -420,7 +420,7 @@ int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
>  
>  int ffurl_write(URLContext *h, const unsigned char *buf, int size)
>  {
> -    if (!(h->flags & AVIO_FLAG_WRITE))
> +    if (!h || !(h->flags & AVIO_FLAG_WRITE))
>          return AVERROR(EIO);
>      /* avoid sending too big packets */
>      if (h->max_packet_size && size > h->max_packet_size)

You shouldn't write to a NULL context, nor should you be able to.
diff mbox

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 63e8287..18e58ae 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -420,7 +420,7 @@  int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
 
 int ffurl_write(URLContext *h, const unsigned char *buf, int size)
 {
-    if (!(h->flags & AVIO_FLAG_WRITE))
+    if (!h || !(h->flags & AVIO_FLAG_WRITE))
         return AVERROR(EIO);
     /* avoid sending too big packets */
     if (h->max_packet_size && size > h->max_packet_size)