[FFmpeg-devel] [PATCH] Fix potential av_find_opt() crash if context is NULL

Michael Niedermayer michaelni
Thu Oct 30 19:54:56 CET 2008


On Thu, Oct 30, 2008 at 04:33:05PM +0100, Stefano Sabatini wrote:
> On date Thursday 2008-10-30 14:32:29 +0100, Michael Niedermayer encoded:
> > On Thu, Oct 30, 2008 at 12:14:36AM +0100, Stefano Sabatini wrote:
> > > On date Wednesday 2008-10-29 00:43:16 +0100, Michael Niedermayer encoded:
> > > > On Wed, Oct 29, 2008 at 12:27:35AM +0100, Stefano Sabatini wrote:
> > > > > Hi, as in patch.
> > > > > 
> > > > > This happens for example in libavfilter-soc with:
> > > > > ffplay -foo x
> > > > > 
> > > > > when --enable-avfilter, in this case sws_opts is NULL.
> > > > 
> > > > could you elaborate a little more how above is causing a NULL
> > > > to be passed.
> > > > All readers surely could guess but i think it would improve the
> > > > responses if everyone would know what happens where 
> > > 
> > > We have:
> > > 
> > > #if !ENABLE_AVFILTER
> > >     sws_opts = sws_getContext(16,16,0, 16,16,0, sws_flags, NULL,NULL,NULL);
> > > #endif
> > > 
> > > So sws_opts is not initialized and is NULL.
> > > 
> > > Then when an unknown option is parsed and processed in opt_default we
> > > have:
> > > 
> > >     if(!o)
> > >         o = av_set_string2(sws_opts, opt, arg, 1);
> > > 
> > > which calls av_find_opt() and crashes.
> > > 
> > > Optionally we could specify in the doc the condition for which
> > > opt_find_opt has to take always a non-NULL value as obj, but I think
> > > it is more robust and semnatically more correct to simply return NULL
> > > in case of a NULL obj.
> > 
> > bleh ...
> > the problem is obvious in the ENABLE_AVFILTER #ifdefs
> > if sws is not used by ffmpegm sws_opts itself should not even exist with
> > avfilter
> 
> Mhh.. so what about this? And I'm not sure it is the best solution...

i think the non null-ness is already implied by the first element being
something.

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

I count him braver who overcomes his desires than him who conquers his
enemies for the hardest victory is over self. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081030/c0999394/attachment.pgp>



More information about the ffmpeg-devel mailing list