Repository navigation
tests: handle missing --max-level argument - #349
Open
1234binpig wants to merge 1 commit into
Open
1234binpig wants to merge 1 commit into
1234binpig wants to merge 1 commit into
Conversation
Both run-parser and run-parser-test-suite incremented the argument index after --max-level without first checking that a value followed. When --max-level was the final argument, this caused argv[argc] to be passed to strtol(). Reject a missing value and exit with an error instead. Signed-off-by: huangwenbin <huangwenbin@kylinos.cn>
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.
Problem
run-parserandrun-parser-test-suiteassume that--max-levelis always followed by a value.When the option is the final command-line argument, both programs increment the argument index past the end of
argvand passargv[argc]tostrtol().Fix
Check that a value follows
--max-levelbefore consuming the next argument.If the value is missing, print usage information and exit with a nonzero status.
Testing
Verified that:
run-parser --max-levelexits with status1;run-parser-test-suite --max-levelexits with status1;--max-level 100usage still succeeds in both tools;git diff --checkpasses.