Permalink
Browse files

Added check on number of tiles to be downloaded, and bail out if abov…

…e treshold.
  • Loading branch information...
1 parent 415ac78 commit 9081bb97faabb761c4d313e751a7602e46e97dab @accumulator accumulator committed Aug 3, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/osm-gps-map-widget.c
View
@@ -145,6 +145,7 @@
#define EXTRA_BORDER (TILESIZE / 2)
#define OSM_GPS_MAP_SCROLL_STEP (10)
#define USER_AGENT "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
+#define MAX_DOWNLOAD_TILES 10000
struct _OsmGpsMapPrivate
{
@@ -2629,6 +2630,13 @@ osm_gps_map_download_maps (OsmGpsMap *map, OsmGpsMapPoint *pt1, OsmGpsMapPoint *
x2 = (int)floor((float)lon2pixel(zoom, pt2->rlon) / (float)TILESIZE);
y2 = (int)floor((float)lat2pixel(zoom, pt2->rlat) / (float)TILESIZE);
+ /* check for insane ranges */
+ if ( (x2-x1) * (y2-y1) > MAX_DOWNLOAD_TILES ) {
+ g_warning("Aborting download of zoom level %d and up, because "
+ "number of tiles would exceed %d", zoom, MAX_DOWNLOAD_TILES);
+ break;
+ }
+
/* loop x1-x2 */
for(i=x1; i<=x2; i++) {
/* loop y1 - y2 */

0 comments on commit 9081bb9

Please sign in to comment.