Skip to content

schema compile BUGFIX quote in a log path value - #2666

Open
Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:log-path-quote
Open

Mohil-Ahuja wants to merge 1 commit into
CESNET:develfrom
Mohil-Ahuja:log-path-quote

Conversation

@Mohil-Ahuja

Copy link
Copy Markdown

lysc_update_path() adds special tag values to the log path quoted with ', for example /aq:{augment='/c/x'}. When the tag is removed again, the backwards scan skips quoted parts so that a = or { inside the value does not end the scan (7fddfaa). A ' inside the value unbalances the quotes. The scan then never finds the =, and it runs past the start of the path. path_used wraps around, and the read lands far outside the buffer.

A module with an augment target such as "/c'x" is enough. A release build crashes in lysc_update_path() called from lys_precompile_mod_augments_deviations():

==909537==ERROR: AddressSanitizer: SEGV on unknown address 0x519100082f7f
    #0 lysc_update_path
    #1 lys_precompile_mod_augments_deviations
    #2 lys_precompile_augments_deviations
    #3 lys_implement

The fix:

  • A value that includes ' is now quoted with ".
  • The scan ends a quoted part only on the quote character that started it.
  • Both backwards scans stop at the start of the path.

The test is added to test_augment in test_tree_schema_compile.c. I found this by fuzzing lys_parse_mem.

A special tag value in the log path, such as the target of an augment,
is quoted with ' and removing it skips the quoted part. A ' inside the
value, as in augment "/c'x", unbalanced the quotes so the backwards
scan went past the start of the path and read out of bounds. Quote the
value with " if it includes ', only end a quoted part with its own
quote character, and never scan before the start of the path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant