]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
genksyms: restrict direct-declarator to take one parameter-type-list
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 13 Jan 2025 15:00:46 +0000 (00:00 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 18 Jan 2025 00:11:46 +0000 (09:11 +0900)
Similar to the previous commit, this change makes the parser logic a
little more accurate.

Currently, genksyms accepts the following invalid code:

    struct foo {
            int (*callback)(int)(int)(int);
    };

A direct-declarator should not recursively absorb multiple
( parameter-type-list ) constructs.

In the example above, (*callback) should be followed by at most one
(int).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Nicolas Schier <n.schier@avm.de>
scripts/genksyms/parse.y

index 03cdd8d53c13af5d9ab82109705ec60f61fa92f0..33a6aab53b69d67bd87f5f42ff928a2a4bf3f54c 100644 (file)
@@ -331,12 +331,16 @@ nested_declarator:
        ;
 
 direct_nested_declarator:
-       IDENT   { $$ = $1; dont_want_type_specifier = false; }
-       | direct_nested_declarator '(' parameter_declaration_clause ')'
+       direct_nested_declarator1
+       | direct_nested_declarator1 '(' parameter_declaration_clause ')'
                { $$ = $4; }
-       | direct_nested_declarator '(' error ')'
+       ;
+
+direct_nested_declarator1:
+       IDENT   { $$ = $1; dont_want_type_specifier = false; }
+       | direct_nested_declarator1 '(' error ')'
                { $$ = $4; }
-       | direct_nested_declarator BRACKET_PHRASE
+       | direct_nested_declarator1 BRACKET_PHRASE
                { $$ = $2; }
        | '(' nested_declarator ')'
                { $$ = $3; }