aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-04-26 16:47:00 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-04-26 16:48:09 +0200
commit5732970a48e9dbc834c1fc95c6d594436b517887 (patch)
treed79ce950a1377e867e275be8f6ae311fdbd8ba89 /src/pipeline.cpp
parent3f348c9da4c004f7b7b6b48cf360cc9b698d0a62 (diff)
downloadPROJ-5732970a48e9dbc834c1fc95c6d594436b517887.tar.gz
PROJ-5732970a48e9dbc834c1fc95c6d594436b517887.zip
pipeline initialization: avoid deep recursion on corrupted PROJ string like https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21889
Diffstat (limited to 'src/pipeline.cpp')
-rw-r--r--src/pipeline.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pipeline.cpp b/src/pipeline.cpp
index 96767143..8c4ac655 100644
--- a/src/pipeline.cpp
+++ b/src/pipeline.cpp
@@ -406,6 +406,16 @@ PJ *OPERATION(pipeline,0) {
int i_pipeline = -1, i_first_step = -1, i_current_step;
char **argv, **current_argv;
+ if( P->ctx->pipelineInitRecursiongCounter == 5 )
+ {
+ // Can happen for a string like:
+ // proj=pipeline step "x="""," u=" proj=pipeline step ste=""[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline p step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ste="[" u=" proj=pipeline step ""x="""""""""""
+ // Probably an issue with the quoting handling code
+ // But doesn't hurt to add an extra safety check
+ proj_log_error (P, "Pipeline: too deep recursion");
+ return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: nested pipelines */
+ }
+
P->fwd4d = pipeline_forward_4d;
P->inv4d = pipeline_reverse_4d;
P->fwd3d = pipeline_forward_3d;
@@ -495,7 +505,9 @@ PJ *OPERATION(pipeline,0) {
err = proj_errno_reset (P);
+ P->ctx->pipelineInitRecursiongCounter ++;
next_step = pj_create_argv_internal (P->ctx, current_argc, current_argv);
+ P->ctx->pipelineInitRecursiongCounter --;
proj_log_trace (P, "Pipeline: Step %d (%s) at %p", i, current_argv[0], next_step);
if (nullptr==next_step) {