Re: [FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing
On 09.11.2014 23:22, Lukasz Marek wrote: set_string_binary crashes with called with val=NULL Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- libavutil/opt.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) Pushed whole patchset ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing
On Mon, Nov 10, 2014 at 06:22:07AM +0100, Lukasz Marek wrote: On 10.11.2014 03:21, Michael Niedermayer wrote: 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.lu...@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 ? Yes, it is inconsistent. I changed to return 0. Also, I added check for length 0 to avoid malloc returned some pointer for 0 bytes block. opt.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) 8cb5253a3e91283bd427ebe3a0124c0f890d0535 0001-lavu-opt-check-for-NULL-before-parsing.patch From e67c9094e67cb01e2ec2dcc0a7da19ed9c03 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Sun, 9 Nov 2014 23:15:58 +0100 Subject: [PATCH 1/4] lavu/opt: check for NULL before parsing LGTM [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing
set_string_binary crashes with called with val=NULL Signed-off-by: Lukasz Marek lukasz.m.lu...@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); + +len = strlen(val); if (len 1) return AVERROR(EINVAL); len /= 2; -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/4] lavu/opt: check for NULL before parsing
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.lu...@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 signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel