extract_extradata: zero initalize the padding bytes in all allocated buffers

Message ID 20180308160834.11140-1-jamrial@gmail.com
State New
Headers show
Series
  • extract_extradata: zero initalize the padding bytes in all allocated buffers
Related show

Commit Message

James Almer March 8, 2018, 4:08 p.m.
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/extract_extradata_bsf.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Luca Barbato March 8, 2018, 8:25 p.m. | #1
On 08/03/2018 17:08, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/extract_extradata_bsf.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 

Sounds good.
James Almer March 8, 2018, 9:29 p.m. | #2
On 3/8/2018 5:25 PM, Luca Barbato wrote:
> On 08/03/2018 17:08, James Almer wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavcodec/extract_extradata_bsf.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
> 
> Sounds good.

Actually, i think the filtered_buf one should zero initialize past the
last written byte instead.

I'll send an updated patch.

Patch

diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 100c60d06..8d341cefc 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -105,6 +105,8 @@  static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
                 ret = AVERROR(ENOMEM);
                 goto fail;
             }
+            memset(filtered_buf->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+
             filtered_data = filtered_buf->data;
         }
 
@@ -114,6 +116,7 @@  static int extract_extradata_h2645(AVBSFContext *ctx, AVPacket *pkt,
             ret = AVERROR(ENOMEM);
             goto fail;
         }
+        memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
         *data = extradata;
         *size = extradata_size;
@@ -171,6 +174,7 @@  static int extract_extradata_vc1(AVBSFContext *ctx, AVPacket *pkt,
             return AVERROR(ENOMEM);
 
         memcpy(*data, pkt->data, extradata_size);
+        memset(*data + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
         *size = extradata_size;
 
         if (s->remove) {
@@ -202,6 +206,7 @@  static int extract_extradata_mpeg124(AVBSFContext *ctx, AVPacket *pkt,
                     return AVERROR(ENOMEM);
 
                 memcpy(*data, pkt->data, *size);
+                memset(*data + *size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
                 if (s->remove) {
                     pkt->data += *size;