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 strings include NUL char #311

Open
shuffle2 opened this issue Jun 1, 2022 · 1 comment
Open

PE strings include NUL char #311

shuffle2 opened this issue Jun 1, 2022 · 1 comment

Comments

@shuffle2
Copy link

shuffle2 commented Jun 1, 2022

i'm using goblin to get the required info from PE headers to construct path of pdb on symbol server. cv.filename retains the NUL terminator and was screwing stuff up. It might be annoying to implement correctly throughout the parser, as iirc some strings are exactly sized while others still keep terminating char (even tho they're sized), and probably others can be either way. It would be great if goblin presented them in a uniform way.

if let Some(cv) = debug.codeview_pdb70_debug_info {
    if cv.filename.len() > 0 && cv.filename[0] == 0 {
        // goblin keeps NUL in str :/
        return None;
    }
    if let Ok(pdb_path) =
        std::str::from_utf8(&cv.filename[..cv.filename.len() - 1])
    {
        if let Some(pdb_name) =
            Path::new(pdb_path).file_name().and_then(|x| x.to_str())
        {
            if let Ok(guid) = uuid::Uuid::from_slice_le(&cv.signature) {
                let specifier =
                    format!("{}{:X}", guid.simple().to_string(), cv.age);
                return Some(format!(
                    "{}/{}/{}",
                    pdb_name, specifier, pdb_name
                ));
            }
        }
    }
}
@m4b
Copy link
Owner

m4b commented Jun 11, 2022

@shuffle2 would you like to investigate this issue/send a PR? :)

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

2 participants