Skip to content

Commit

Permalink
validate amount of characters read
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Oct 25, 2024
1 parent 7cc3a29 commit 31d7558
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public void accept(Visitor visitor)
private void validateVersion(InputStreamReader definitionStream) throws IOException {
// only consume chars for the version
char[] versionChars = new char [2];
definitionStream.read(versionChars);
if (versionChars[0] == 'v')
if (definitionStream.read(versionChars) == 2 && versionChars[0] == 'v')
{
switch (versionChars[1])
{
Expand All @@ -120,7 +119,7 @@ private void validateVersion(InputStreamReader definitionStream) throws IOExcept
}
}
else
throw new UnpickSyntaxException(1, "Missing version");
throw new UnpickSyntaxException(1, "Missing or invalid version");
}

private void visitParameterConstantGroupDefinition(Visitor visitor, String[] tokens, int lineNumber)
Expand Down

0 comments on commit 31d7558

Please sign in to comment.