[FFmpeg-devel] [PATCH] pixdesc: Only check against valid entries when iterating over lists of enums

Michael Niedermayer michael at niedermayer.cc
Sat Jun 9 20:31:26 EEST 2018


On Fri, Jun 08, 2018 at 04:47:05PM +0100, Derek Buitenhuis wrote:
> Some of these enums have gaps in between their values, since they correspond
> to the values in various specs, instead of being an incrementing list.
> 
> Fixes segfaults when, for example, using the valid API call:
> 
>    av_color_primaries_from_name("jecdec-p22");
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
>  libavutil/pixdesc.c | 35 ++++++++++++++++++++++++++++++-----
>  1 file changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index ff5c20d50e..f849222aa3 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -2718,7 +2718,12 @@ int av_color_range_from_name(const char *name)
>      int i;
>  
>      for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
> -        size_t len = strlen(color_range_names[i]);
> +        size_t len;
> +
> +        if (!color_range_names[i])
> +            continue;
> +
> +        len = strlen(color_range_names[i]);
>          if (!strncmp(color_range_names[i], name, len))
>              return i;
>      }

theres no hole in color_range_names
this may lead to static analyzers complaining about dead code

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180609/755ed57c/attachment.sig>


More information about the ffmpeg-devel mailing list