Skip to content

Commit 252e8a2

Browse files
authored
Merge pull request OSGeo#3736 from rouault/fix_3732
tinshift: raise maximum size of JSON file to 100 MB (fixes OSGeo#3732)
2 parents f4a63f4 + 91748f8 commit 252e8a2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/transformations/tinshift.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,20 @@ PJ *TRANSFORMATION(tinshift, 1) {
9494
file->seek(0, SEEK_END);
9595
unsigned long long size = file->tell();
9696
// Arbitrary threshold to avoid ingesting an arbitrarily large JSON file,
97-
// that could be a denial of service risk. 10 MB should be sufficiently
97+
// that could be a denial of service risk. 100 MB should be sufficiently
9898
// large for any valid use !
99-
if (size > 10 * 1024 * 1024) {
99+
if (size > 100 * 1024 * 1024) {
100100
proj_log_error(P, _("File %s too large"), filename);
101101
return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);
102102
}
103103
file->seek(0);
104104
std::string jsonStr;
105-
jsonStr.resize(static_cast<size_t>(size));
105+
try {
106+
jsonStr.resize(static_cast<size_t>(size));
107+
} catch (const std::bad_alloc &) {
108+
proj_log_error(P, _("Cannot read %s. Not enough memory"), filename);
109+
return destructor(P, PROJ_ERR_OTHER);
110+
}
106111
if (file->read(&jsonStr[0], jsonStr.size()) != jsonStr.size()) {
107112
proj_log_error(P, _("Cannot read %s"), filename);
108113
return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);

0 commit comments

Comments
 (0)