[patch][bugfix]Http mp4: replace strtod() with improved ngx_atofp() because precision problem.

Maxim Dounin mdounin at mdounin.ru
Wed Oct 26 17:56:52 UTC 2016


Hello!

On Thu, Oct 27, 2016 at 12:40:21AM +0800, 胡聪 (hucc) wrote:

> Hello!
> 
> On Wed, Oct 26, 2016 at 8:31PM, Maxim Dounin wrote:
> 
> >On Wed, Oct 26, 2016 at 05:10:25PM +0800, 胡聪 (hucc) wrote:
> > 
> >> VOD (video on demand) module which support requesting time range
> >> also need the special function, so i would like to see that nginx-devel
> >> add a function in Core, that would be helpful. Possible patch below.
> >
> >If you mean https://github.com/kaltura/nginx-vod-module, then I 
> >don't think it does.  Quick look suggests that it uses 
> >milliseconds to specify times instead, and uses ngx_atoi() to 
> >parse them.  It doesn't use strtod() at all, and the only place it 
> >uses ngx_atofp() now is to parse rate, and I don't think there are 
> >reasons to allow arbitrary numbers like in the mp4 case.
> >
> >The main problem with mp4 was that there were existing Flash 
> >clients nginx has to be compatible with, and some of them used to 
> >send incorrect start time specifications.  It is highly unlikely 
> >that the same unique situation affects other modules.
> 
> I don`t know how to make a more specific description because of my
> poor english.  What i mean about VOD is video-processing module in
> CDN provider, this scenario usually be asked to provide parameter
> parsing which support seconds and milliseconds.  I am developing a
> series of moudles which are a bit like nginx-vod-module and new
> function will be used based on my experience.  I just think the usage
> of atofp() is very limited, maybe a function supporting optional mode
> should be provided.  Anyway, the point is whether other modules
> need new function, i pointed out the scene i familiar with and hope
> this helps.

There is no problem with parsing seconds and milliseconds using 
ngx_atofp().  The problem with ngx_atofp() only appears if you 
have to support existing clients who already use invalid syntax.  
Unless you have to support such clients - you'd better use generic 
ngx_atofp() and reject attempts to use invalid syntax in the 
arguments.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list