Commit 5d5a7d88 authored by Wander Lairson Costa's avatar Wander Lairson Costa Committed by Gabriele Monaco
Browse files

rv/rvgen: fix DOT file validation logic error



Fix incorrect boolean logic in automata DOT file format validation
that allowed malformed files to pass undetected. The previous
implementation used a logical AND operator where OR was required,
causing the validation to only reject files when both the first
token was not "digraph" AND the second token was not
"state_automaton". This meant a file starting with "digraph" but
having an incorrect second token would incorrectly pass validation.

The corrected logic properly rejects DOT files where either the
first token is not "digraph" or the second token is not
"state_automaton", ensuring that only properly formatted automaton
definition files are accepted for processing. Without this fix,
invalid DOT files could cause downstream parsing failures or
generate incorrect C code for runtime verification monitors.

Signed-off-by: default avatarWander Lairson Costa <wander@redhat.com>
Reviewed-by: default avatarNam Cao <namcao@linutronix.de>
Reviewed-by: default avatarGabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/r/20260223162407.147003-10-wander@redhat.com


Signed-off-by: default avatarGabriele Monaco <gmonaco@redhat.com>
parent 0d5c9f10
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class Automata:
        # checking the first line:
        line = dot_lines[cursor].split()

        if (line[0] != "digraph") and (line[1] != "state_automaton"):
        if (line[0] != "digraph") or (line[1] != "state_automaton"):
            raise AutomataError(f"Not a valid .dot format: {self.__dot_path}")
        else:
            cursor += 1