[gdal-dev] WMS MINRESOLUTION can lead to overflow of raster dimensions
Even Rouault
even.rouault at spatialys.com
Mon Nov 23 13:25:02 PST 2015
Tim,
> Would it make sense to do something as follows? (Note: I haven't tried
> this yet, I'm just soliciting early feedback so please bare with me )
>
>
> if (osMinResolution.size() != 0)
> {
> double dfMinResolution = CPLAtofM(osMinResolution);
>
> while (nOverviewCount > 20)
> {
> nOverviewCount --;
> dfMinResolution *= 2;
> }
>
> // *** Changes here ***
> // Determine a suitable resolution that doesn't overflow max int.
> double dXSize = ((dfMaxX - dfMinX) / dfMinResolution + 0.5);
> double dYSize = ((dfMaxY - dfMinY) / dfMinResolution + 0.5);
>
> while (dXSize > INT_MAX || dYSize > INT_MAX)
> {
> nOverviewCount --;
I'm not sure we need to decrement the number of overviews in that loop.
> dfMinResolution *= 2;
>
> dXSize = ((dfMaxX - dfMinX) / dfMinResolution + 0.5);
> dYSize = ((dfMaxY - dfMinY) / dfMinResolution + 0.5);
> }
>
> nXSize = (int) dXSize;
> nYSize = (int) dYSize;
> }
>
> Any thoughts?
If that works, please open a ticket with the patch.
For extra bonus, I see that a few lines below a similar overflow could also
occur :
"""
else
{
double dfRatio = (dfMaxX - dfMinX) / (dfMaxY - dfMinY);
if (dfRatio > 1)
{
nXSize = nTileSize;
nYSize = (int) (nXSize / dfRatio);
}
else
{
nYSize = nTileSize;
nXSize = (int) (nYSize * dfRatio);
}
if (nOverviewCount < 0 || nOverviewCount > 20)
nOverviewCount = 20;
nXSize = nXSize * (1 << nOverviewCount);
nYSize = nYSize * (1 << nOverviewCount);
}
"""
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list