Repository navigation
scanner: don't let an open comment or string leak out of an include file - #316
Merged
Merged
Conversation
The <<EOF>> rule moves on to the next file of an @include list, or back to the including file, without resetting the start condition. So an included file that ends inside a /* comment, a string or an @include path keeps scanning the next file in that state, and a block comment silently drops every setting after the @include while the read still succeeds. End a line comment at the end of its file, and fail an included file that ends in any other state with "unexpected end of include file". Top-level files are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro: put
@include "frag.cfg"in a file, followed byadmin = false;, and end frag.cfg withcolor = "blue"; /* notes.config_read_file()returns true andadminis simply gone.Cause: the
<<EOF>>rule moves on to the next include file, or back to the parent, without resetting the start condition, so an open block comment, string or@includepath carries on into the next file. A#comment on the last line with no trailing newline also eats whatever follows on the@includeline, or the first line of the next file in an include list.Fix: end a line comment at end of file, and fail an included file that ends in any other state with "unexpected end of include file", reported against that file. Top-level files behave as before, so existing configs that end in an open comment still load; happy to make those strict too if you'd prefer. scanner.c/scanner.h match flex 2.6.4 output, and the new IncludeUnterminated test fails without the fix.