]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: refuse empty () structs/enums
authorLennart Poettering <lennart@poettering.net>
Thu, 12 Oct 2023 13:21:50 +0000 (15:21 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Oct 2023 13:25:16 +0000 (15:25 +0200)
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

index 73f336c522ec947a3aac9b8660f0954527785b59..98d97892ec109e37320bd7dae2dac509cb94a6b9 100644 (file)
@@ -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;
 }