Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Dec 5, 2025

Check for readBytes being less than 0, not -1.

It returns -1 when there's an error

Check for readBytes being less than 0, not -1
@AZero13 AZero13 changed the title Fix off by one error [FileManager] Fix off by one error Dec 5, 2025
@AZero13
Copy link
Contributor Author

AZero13 commented Dec 5, 2025

@itingliu Hi, could you please check this

@AZero13
Copy link
Contributor Author

AZero13 commented Dec 5, 2025

@compnerd

}
}
if readBytes < -1 { return false }
if readBytes < 0 { return false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a unit test that could be added to validate this behavior to confirm that the change works as intended and it doesn't regress in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How am I supposed to make a unit test that causes read, an OS syscall, to fail reliably?

@AZero13 AZero13 requested a review from jmschonfeld December 5, 2025 22:24
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.

2 participants