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

pe::symbol::Symbol::name skips the first 4 characters of a symbol's name #318

Closed
SquareMan opened this issue Jul 25, 2022 · 0 comments
Closed

Comments

@SquareMan
Copy link
Contributor

This is a new issue in Goblin 0.5 and appears to have been introduced by #310

The beginning of a COFF object file's string table is the overall length of the string table. Symbol's name offsets are based on index 0 being the beginning of the string table, therefore including the length. #310 prevented this length from being parsed as strings, but in doing so has caused string lookups for symbols to be off by 4.

I've written this failing test to complement the one added in #310 that demonstrates the issue.

src/pe/mod.rs

    #[test]
    fn symbol_name_excludes_length() {
        let coff = Coff::parse(&COFF_FILE_SINGLE_STRING_IN_STRING_TABLE).unwrap();
        let strings = coff.strings;
        let symbols = coff
            .symbols
            .iter()
            .filter(|(_, name, _)| name.is_none())
            .map(|(_, _, sym)| sym.name(&strings).unwrap().to_owned())
            .collect::<Vec<_>>();
        assert_eq!(symbols, vec!["ExitProcess"])
    }

Is there insight as to where the root of the issue lies?

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

No branches or pull requests

1 participant