[FFmpeg-devel] [PATCH] avutil/encryption_info: Don't pass NULL to memcpy

Tomas Härdin tjoppen at acc.umu.se
Wed Sep 18 21:20:10 EEST 2019


ons 2019-09-18 klockan 02:03 +0200 skrev Andreas Rheinhardt:
> The pointer arguments to memcpy (and several other functions of the
> C standard library) are not allowed to be NULL, not even when the number
> of bytes to copy is zero. An AVEncryptionInitInfo's data pointer is
> explicitly allowed to be NULL and yet av_encryption_init_info_add_side_data
> unconditionally used it as a source pointer to copy from. This commit changes
> this so that copying is only done if the number of bytes to copy is > 0.

*gesticulates wildly with a formal verification stick*

> -        memcpy(cur_buffer, cur_info->data, cur_info->data_size);
> -        cur_buffer += cur_info->data_size;
> +        if (cur_info->data_size > 0) {
> +            memcpy(cur_buffer, cur_info->data, cur_info->data_size);
> +            cur_buffer += cur_info->data_size;
> +        }

Approve

There's no doubt more of these

/Tomas



More information about the ffmpeg-devel mailing list