Ventoy icon indicating copy to clipboard operation
Ventoy copied to clipboard

Add length check on command line input

Open celine-lee opened this issue 3 years ago • 1 comments

My team and I were looking through the Ventoy source code using our AI-based source code anomaly detection tool, MP-CodeCheck, and found this line that, while currently functioning correctly, may benefit from a slight adjustment for the sake of maintainability: a check on the length of the input string argv[1] before checking its first two characters.

This way, a developer who may modify this line in the future, especially if the program checks for longer string prefixes, will be more likely to be conscious of valid string checking to avoid undefined behavior.

celine-lee avatar Apr 06 '22 06:04 celine-lee

IMHO, the check is unnecessary because of short-circuiting in if statement.

ventoy avatar Apr 06 '22 07:04 ventoy