[FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing

Michael Niedermayer michaelni at gmx.at
Mon Nov 10 03:21:41 CET 2014


On Sun, Nov 09, 2014 at 11:22:46PM +0100, Lukasz Marek wrote:
> set_string_binary crashes with called with val=NULL
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> ---
>  libavutil/opt.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/opt.c b/libavutil/opt.c
> index fca5354..bc62044 100644
> --- a/libavutil/opt.c
> +++ b/libavutil/opt.c
> @@ -126,11 +126,15 @@ static int set_string_binary(void *obj, const AVOption *o, const char *val, uint
>  {
>      int *lendst = (int *)(dst + 1);
>      uint8_t *bin, *ptr;
> -    int len = strlen(val);
> +    int len;
>  
>      av_freep(dst);
>      *lendst = 0;
>  
> +    if (!val)
> +        return AVERROR(EINVAL);

this deallocates dest and then returns failure
shouldnt it either not fail or not change the state of dst ?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141110/ef631714/attachment.asc>


More information about the ffmpeg-devel mailing list