File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -94,15 +94,20 @@ PJ *TRANSFORMATION(tinshift, 1) {
94
94
file->seek (0 , SEEK_END);
95
95
unsigned long long size = file->tell ();
96
96
// 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
98
98
// large for any valid use !
99
- if (size > 10 * 1024 * 1024 ) {
99
+ if (size > 100 * 1024 * 1024 ) {
100
100
proj_log_error (P, _ (" File %s too large" ), filename);
101
101
return destructor (P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);
102
102
}
103
103
file->seek (0 );
104
104
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
+ }
106
111
if (file->read (&jsonStr[0 ], jsonStr.size ()) != jsonStr.size ()) {
107
112
proj_log_error (P, _ (" Cannot read %s" ), filename);
108
113
return destructor (P, PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID);
You can’t perform that action at this time.
0 commit comments