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

Convert bad file to valid hex file #279

Closed
wants to merge 1 commit into from
Closed

Conversation

jose-pr
Copy link

@jose-pr jose-pr commented Jul 29, 2021

Fixes what #277 tried to fix, changing the name alone wont fix the problem as the renamed file still contains the GZ magic number and will still be detected by a file scanner as a corrupt GZ file.
Used the following to generate the hex file.

fn bin_to_hex(bin_reader: impl Read, hex_writer: impl Write) {
    let bin_reader = BufReader::new( bin_reader);
    let mut hex_writer = BufWriter::new( hex_writer);

    for byte in bin_reader.bytes() {
        let byte = byte.unwrap();
        write!(hex_writer, "{:X} ", byte).unwrap();
    }

    hex_writer.flush().unwrap();
}

Fixes what rust-lang#277 tried to fixed, changing the name alone wont fix the problem as the renamed file still contains the GZ magic number and will still be detected by a file scanner as a corrupt GZ file.
Used the following to generate the hex file.

```
fn bin_to_hex(bin_reader: impl Read, hex_writer: impl Write) {
    let bin_reader = BufReader::new( bin_reader);
    let mut hex_writer = BufWriter::new( hex_writer);

    for byte in bin_reader.bytes() {
        let byte = byte.unwrap();
        write!(hex_writer, "{:X} ", byte).unwrap();
    }

    hex_writer.flush().unwrap();
}
```
@alexcrichton
Copy link
Member

Sorry I don't want to make files like this too complicated in this repo, and I think that this is a step too far. I think if automated scanners are tripping up over this file then there's only so much this repository can do before something should be fixed in the scanner itself.

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