Skip to content

Commit 7f843c4

Browse files
committed
Check integrity of sqlite3 file before decoding or tile-joining
1 parent 3cea125 commit 7f843c4

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.27.12
2+
3+
* Check integrity of sqlite3 file before decoding or tile-joining
4+
15
## 1.27.11
26

37
* Always include tile and layer in tippecanoe-decode, fixing corrupt JSON.

decode.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> co
274274
fprintf(stderr, "%s: %s\n", fname, sqlite3_errmsg(db));
275275
exit(EXIT_FAILURE);
276276
}
277+
278+
char *err = NULL;
279+
if (sqlite3_exec(db, "PRAGMA integrity_check;", NULL, NULL, &err) != SQLITE_OK) {
280+
fprintf(stderr, "%s: integrity_check: %s\n", fname, err);
281+
exit(EXIT_FAILURE);
282+
}
277283
}
278284

279285
if (z < 0) {

enumerate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ void enumerate(char *fname) {
1111
exit(EXIT_FAILURE);
1212
}
1313

14+
char *err = NULL;
15+
if (sqlite3_exec(db, "PRAGMA integrity_check;", NULL, NULL, &err) != SQLITE_OK) {
16+
fprintf(stderr, "%s: integrity_check: %s\n", fname, err);
17+
exit(EXIT_FAILURE);
18+
}
19+
1420
const char *sql = "SELECT zoom_level, tile_column, tile_row from tiles order by zoom_level, tile_column, tile_row;";
1521

1622
sqlite3_stmt *stmt;

tile-join.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ struct reader *begin_reading(char *fname) {
413413
exit(EXIT_FAILURE);
414414
}
415415

416+
char *err = NULL;
417+
if (sqlite3_exec(db, "PRAGMA integrity_check;", NULL, NULL, &err) != SQLITE_OK) {
418+
fprintf(stderr, "%s: integrity_check: %s\n", fname, err);
419+
exit(EXIT_FAILURE);
420+
}
421+
416422
const char *sql = "SELECT zoom_level, tile_column, tile_row, tile_data from tiles order by zoom_level, tile_column, tile_row;";
417423
sqlite3_stmt *stmt;
418424

version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef VERSION_HPP
22
#define VERSION_HPP
33

4-
#define VERSION "tippecanoe v1.27.11\n"
4+
#define VERSION "tippecanoe v1.27.12\n"
55

66
#endif

0 commit comments

Comments
 (0)