Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2800: return unsigned byte by InputStream API (-1 just if EOF) #2834

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

lfcnassif
Copy link
Contributor

Fix #2800. Returns unsigned byte according to method contract, avoiding to return -1 before EOF.

@lfcnassif
Copy link
Contributor Author

lfcnassif commented Aug 5, 2023

Could someone review this? All modules calling ReadContentInputStream.read() method can be affected and stop processing files before EOF.

@markmckinnon
Copy link
Contributor

Do you have a sample dataset that causes the error that you can provide to expedite testing?

@lfcnassif
Copy link
Contributor Author

Fix is just an one line change.

@lfcnassif
Copy link
Contributor Author

Do you have a sample dataset that causes the error that you can provide to expedite testing?

We were affected by this on our project because some modules use the affected method. I don't know if TSK or Autopsy use this public method, but if not it may be used in the future.

To reproduce the error just create a file with a 0xFF as starting byte and more random bytes. Try to read that whole file using just the mentioned method, checking if the returned value is EOF (-1) after each read. The EOF (-1) will be returned in the first read, although the file is not 0 sized.

@markmckinnon markmckinnon self-requested a review August 5, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReadContentInputStream.read() method returning wrong values
2 participants