Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 9.2] tinshift: raise maximum size of JSON file to 100 MB (fixes #3732) #3739

Merged
merged 1 commit into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/transformations/tinshift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,20 @@ PJ *TRANSFORMATION(tinshift, 1) {
file->seek(0, SEEK_END);
unsigned long long size = file->tell();
// Arbitrary threshold to avoid ingesting an arbitrarily large JSON file,
// that could be a denial of service risk. 10 MB should be sufficiently
// that could be a denial of service risk. 100 MB should be sufficiently
// large for any valid use !
if (size > 10 * 1024 * 1024) {
if (size > 100 * 1024 * 1024) {
proj_log_error(P, _("File %s too large"), filename);
return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);
}
file->seek(0);
std::string jsonStr;
jsonStr.resize(static_cast<size_t>(size));
try {
jsonStr.resize(static_cast<size_t>(size));
} catch (const std::bad_alloc &) {
proj_log_error(P, _("Cannot read %s. Not enough memory"), filename);
return destructor(P, PROJ_ERR_OTHER);
}
if (file->read(&jsonStr[0], jsonStr.size()) != jsonStr.size()) {
proj_log_error(P, _("Cannot read %s"), filename);
return destructor(P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);
Expand Down