Repository navigation
nvme: fix the JSON document count and label the remaining error messages - #4231
Merged
Merged
Conversation
nvme_main() finishes the output even if no command started a document, e.g. after a usage error. json_show_finish() then counts json_init below zero, and the next document is not printed. This hits the fuzz tests, which run nvme_main() over and over. Ignore a finish without a start. Signed-off-by: Daniel Wagner <dwagner@suse.de>
The errors of a command start with its name since commit 32f59da ("nvme: start the error messages with the name of the command"), the usage errors before a command runs with the program name. Some messages still start with "ERROR:" instead, e.g. $ nvme id crrl ERROR: Invalid sub-command 'crrl' for plugin id $ nvme id ctrl /dev/nvme0 id ctrl: /dev/nvme0: Permission denied Add argconfig_error(), which labels a message as the usage errors do, and use it for the errors of the plugin dispatch and of the privilege separation, which run before or around a command: id: invalid sub-command 'crrl' The two checks of the deprecated tls-key command are usage errors and now print its usage as well. A negative status no longer adds "Error:" after the label. The e2e tests detect a missing sub-command by its error message, also of older nvme-cli versions. Match it case-insensitively. Signed-off-by: Daniel Wagner <dwagner@suse.de>
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.
Two fixes, split out of the decoder sandbox work (#4183):
nvme-print-json: don't finish a document which was not started
nvme_main()finishes the output even if no command started a document, e.g. after a usage error.json_show_finish()then countsjson_initbelow zero, and the next document is never printed. This hits the fuzz tests, which runnvme_main()over and over.nvme: start the remaining error messages with a label
Since 32f59da the errors of a command start with its name. A few messages still print their own
ERROR:prefix:argconfig_error()labels a message the way the usage errors are labelled: with the command name, or before a command runs with the program name. The plugin dispatch and the privilege separation use it now (id: invalid sub-command 'crrl'). The two checks of the deprecatedtls-keycommand become usage errors, and a negative status no longer printsid ctrl: Error: ....The e2e tests detect a missing sub-command by its error message, also on older nvme-cli versions; they now match it case-insensitively.
Tested: full test suite, both commits built on their own, checkpatch with the CI filter.