[ovs-dev] [PATCH v3] expr: Set a limit on the depth of nested parentheses

Ben Pfaff blp at ovn.org
Thu Oct 11 20:02:37 UTC 2018


On Wed, Oct 10, 2018 at 03:15:52PM -0700, Yifeng Sun wrote:
> This patch checks the depth of nested parentheses to prevent
> stack overflow. Since is_chassis_resident doesn't allow
> nested parentheses, its following parentheses are not taken
> into acount in the parentheses-depth context.
> 
> Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10714
> Signed-off-by: Yifeng Sun <pkusunyifeng at gmail.com>
> Suggested-by: Ben Pfaff <blp at ovn.org>
> ---
> v1->v2: Handle parse_chassis_resident and add new test, thanks Ben!
> v2->v3: Ignore parentheses from chassis resident.

Thanks a lot for the updated patch.

The grammar of the error message wasn't quite right, so I adjusted it.

I wanted to always keep the depth counter correct, even if there was an
error, so I moved the updates, like this:

        if (ctx->paren_depth >= MAX_PAREN_DEPTH) {
            lexer_error(ctx->lexer, "Parentheses nested too deeply.");
            return NULL;
        }

        ctx->paren_depth++;
        struct expr *e = expr_parse__(ctx);
        ctx->paren_depth--;

The unbalanced parentheses in the test were confusing my editor, so I
balanced them.

And then I applied this to master and backported it as far as
branch-2.7.  Thanks again!


More information about the dev mailing list