[FFmpeg-cvslog] r9733 - trunk/libavformat/os_support.c

Uoti Urpala uoti.urpala
Thu Jul 19 10:38:04 CEST 2007


On Thu, 2007-07-19 at 10:17 +0200, Benoit Fouet wrote:
> M?ns Rullg?rd wrote:
> >>      add1 = atoi(pch);
> >>      pch = strpbrk(pch,".");
> >> -    if (pch == 0 || ++pch == 0) return 0;
> >> +    if (!pch) return 0;
> >>      add2 = atoi(pch);

> > This is wrong.  The ++ is needed.  Whoever wrote this code was very
> > confused.
> >   
> 
> then the right thing to do would be:
> if(!pch) return 0;
> addX = atoi(++pch);
> 
> right ? tome, the check of ++pch is really unneeded

The ++ is needed to move over the '.', but yes check against 0 will
always be false. The next character of the string (there must be one if
the string is 0-terminated and the current character is not 0) will not
be at address 0.

I guess it was meant to be a check against the pointed-to character
being the terminating 0. However even with that the error checking in
that function would be really weak - it'll accept addresses such as
"1.12foo.bar.something.32000.1.1.2" (I think that would be parsed the
same as "1.12.0.0").





More information about the ffmpeg-cvslog mailing list