From 6fa09278b8ae30c672451dbcfd05a7d5f072fe71 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 12 Oct 2023 15:21:50 +0200 Subject: [PATCH] varlink: refuse empty () structs/enums If we encounter an empty struct in the varlink IDL it could also be an empty enum. Refuse this to avoid the ambiguity. The spec doesn't cover this case clearly, hence let's better be on the safe side and refuse it rather than making a decision what it means. --- src/shared/varlink-idl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/varlink-idl.c b/src/shared/varlink-idl.c index 73f336c522e..98d97892ec1 100644 --- a/src/shared/varlink-idl.c +++ b/src/shared/varlink-idl.c @@ -828,6 +828,11 @@ static int varlink_idl_subparse_struct_or_enum( } } + /* If we don't know the type of the symbol by now it was an empty () which doesn't allow us to + * determine if we look at an enum or a struct */ + if ((*symbol)->symbol_type < 0) + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "%u:%u: Ambiguous empty () enum/struct is not permitted.", *line, *column); + return 0; } -- 2.47.3