[gdal-dev] WMS MINRESOLUTION can lead to overflow of raster dimensions

Timothy Astle timothy.astle at caris.com
Tue Nov 24 07:50:48 PST 2015


Thanks for the feedback Even, comments inline below.

On 23/11/2015 5:25 PM, Even Rouault wrote:
> 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.

Good point.

>
>>               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 :

Sounds like a plan to me.

>
> """
>      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
>

-- 
Tim Astle
Development Manager for Web Technologies

*CARIS* <http://www.caris.com>
115 Waggoners Lane
Fredericton, New Brunswick
Canada    E3B 2L4
Tel: +1.506.458.8533     Fax: +1.506.459.3849
www.caris.com <http://www.caris.com>

*Connect with CARIS*
Twitter <http://www.twitter.com/CARIS_GIS> | LinkedIn 
<http://www.linkedin.com/groups?mostPopular=&gid=3217878> | Facebook 
<https://www.facebook.com/pages/CARIS-The-Marine-GIS-Experts/123907500987669?v=app_4949752878> 
| Google+ 
<https://plus.google.com/b/114389770462919844434/114389770462919844434/posts> 
| YouTube <http://www.youtube.com/user/CARISGIS>

Download your free copy of CARIS Easy View today!
www.caris.com/easyview <http://www.caris.com/easyview>

_________________________________________________________________________
This email and any files transmitted with it are confidential and 
intended only for the addressee(s). If you are not the intended 
recipient(s) please notify us by email reply. You should not use, 
disclose, distribute or copy this communication if received in error.

Any views or opinions expressed in this email are solely those of the 
author and do not necessarily represent those of the company. No binding 
contract will result from this email until such time as a written 
document is signed on behalf of the company.



More information about the gdal-dev mailing list