Repository navigation
Conversation
`stream_names` indexed the names block with the `name_offset` values taken verbatim from the names map. An offset past the end of the block panicked on the slice range check, in release too, before any DBI or module data was read. Return `UnexpectedEof` for that entry, the same error the loop already returns for a name that is not NUL-terminated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PDBInformation::stream_namesindexed the names block with thename_offsetvalues taken verbatim from the names map, without checking them againstnames_buf.len():A names-map entry with
name_offset = 0xFFFF0000therefore panicked on the slice range check, in release too, before any DBI or module data was read:The loop already returns
Error::UnexpectedEoffor a name that is not NUL-terminated, so an offset past the end of the block now returns the same error instead of panicking:Tests
Added two tests to
tests/pdb_information.rsthat build a 4 KiB MSF in memory, with the PDB Information stream holding one named stream and a 5-byte names block:stream_names_reads_a_name_offset_inside_the_names_blockusesname_offset = 2and asserts the name is"b". It pins that the fixture is otherwise valid, so the error in the next test comes from the offset alone.stream_names_rejects_a_name_offset_past_the_names_blockusesname_offset = 0xFFFF0000and assertsstream_names()returns an error.Before the fix the second test panics with the message above; after it, both pass:
cargo testpasses 83 lib tests and the other integration tests.tests/id_information.rsfails on this checkout because it needsscripts/downloadto fetch its fixture; that is unrelated to this change.cargo fmt --checkis clean, andcargo clippy --all-features --workspace --tests --examples -- -D clippy::allreports nothing insrc/pdbi.rsor the new test (the 14 errors it prints are pre-existing lints indbi.rs,modi/,msf/andtpi/).Fixes #171.