From e2b9b96ba8209fd85eb97d2d7163e4c1ac5f5b40 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Mon, 30 Oct 2017 12:55:22 -0700 Subject: [PATCH] Detect impossible zoom levels in mbtiles when decoding --- decode.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decode.cpp b/decode.cpp index 5121d8af..fc3f0745 100644 --- a/decode.cpp +++ b/decode.cpp @@ -247,6 +247,12 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set co int tz = sqlite3_column_int(stmt, 1); int tx = sqlite3_column_int(stmt, 2); int ty = sqlite3_column_int(stmt, 3); + + if (tz < 0 || tz >= 32) { + fprintf(stderr, "Impossible zoom level %d in mbtiles\n", tz); + exit(EXIT_FAILURE); + } + ty = (1LL << tz) - 1 - ty; const char *s = (const char *) sqlite3_column_blob(stmt, 0);