Skip to content

Conversation

@glslang
Copy link

@glslang glslang commented Dec 1, 2025

No description provided.

Copy link
Contributor

@kkent030315 kkent030315 left a comment

Choose a reason for hiding this comment

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

Perfect PR. LGTM, Thank you!


// Handle completely invalid offset
if offset >= bytes.len() {
if offset > bytes.len() {
Copy link
Owner

Choose a reason for hiding this comment

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

sorry doesn't this mean offset is pointing to bytes.len() in some cases, which is an OOB if we did bytes[offset] ?

Copy link
Author

Choose a reason for hiding this comment

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

The code at https://github.com/m4b/goblin/blob/master/src/pe/header.rs#L870 adds the length to the offset which makes an empty string table offset to be equal to bytes.len().

The test succeeds and then an empty slice is created at https://github.com/m4b/goblin/blob/master/src/strtab.rs#L62 which should be safe.

I think offset can only be equal to bytes.len() when len is zero, as per https://github.com/m4b/goblin/blob/master/src/pe/header.rs#L862

Alternatively, in header.rs it could be parsed_with_opts and make it permissive.

Copy link
Owner

Choose a reason for hiding this comment

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

Could you add a version (maybe shorter/more condensed) of this reply as a comment above that check? I feel like in the future someone may suspect this was a typical off by one error but apparently it’s a quirk to parsing

Copy link
Author

Choose a reason for hiding this comment

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

Added a comment to the check.

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.

3 participants