Skip to content

FastBufferedReader.skip accepts negative counts and corrupts its position #9

Closed

Description

@PHJ2000

FastBufferedReader.skip() accepts negative counts and changes its buffer position instead of rejecting them:

try (FastBufferedReader reader = new FastBufferedReader(new StringReader("abc"))) {
    reader.skip(-1); // returns -1 instead of throwing IllegalArgumentException
    reader.read();  // ArrayIndexOutOfBoundsException
}

After a successful read, a negative skip can also move backwards through the buffered data. For example, reading a, skipping -1 and reading again returns a again. Reader.skip() specifies IllegalArgumentException for a negative count; rejecting it should leave the position unchanged.

Source checkout: master at b25c27523313dc4406c9055031f76a851a3e0a9d.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions