Skip to content

Caused segfault happened in nxt_conf_op_compile(). #365

@hongzhidao

Description

@hongzhidao

Hi.

The following operations can cause fegfault.

# conf.json
{
    "listeners": {
        "*:8080": {
            "pass":"routes"
        }

    },

    "routes": [
        {
            "match": {
                "uri": "/"
            },

            "action": {
                "share":"/tmp/html"
            }
        }
    ]
}
curl -X PUT -d '"/"' http://127.1:8000/config/routes/0/match/uri/0
curl -X PUT -d '"/"' http://127.1:8000/config/routes/0/match/uri/a

Here's the patch. Take a look, please.

# HG changeset patch
# User hongzhidao <[email protected]>
# Date 1577705904 -28800
# Node ID 1fcb5fba6ab659cd1f4be71b87b567c7b6769360
# Parent  96e6ac1926f86faf542cf380a8d2eadebd3eac5b
Fixed segfault happened in nxt_conf_op_compile().

diff -r 96e6ac1926f8 -r 1fcb5fba6ab6 src/nxt_conf.c
--- a/src/nxt_conf.c	Thu Dec 26 17:04:37 2019 +0300
+++ b/src/nxt_conf.c	Mon Dec 30 19:38:24 2019 +0800
@@ -814,6 +814,10 @@

         default:
             node = NULL;
+
+            if (parse.last) {
+                return NXT_CONF_OP_NOT_FOUND;
+            }
         }

         if (parse.last) {

BTW, how to run UNIT tests beside make tests?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions