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

Multiple panics caused by malformed inputs #53

Open
lizhuohua opened this issue Apr 20, 2021 · 0 comments
Open

Multiple panics caused by malformed inputs #53

lizhuohua opened this issue Apr 20, 2021 · 0 comments

Comments

@lizhuohua
Copy link

Multiple runtime panics can be triggerred by constructing malformed data structures or function arguments. I believe the API design can be improve the get rid of these problems.

Examples:

use brotli::enc::command::BrotliDistanceParams;
use brotli::enc::command::Command;

fn main() {
    let mut command = Command::default();
    command.dist_prefix_ = 1000;
    let params = BrotliDistanceParams {
        distance_postfix_bits: 40,
        num_direct_distance_codes: 0,
        alphabet_size: 0,
        max_distance: 0,
    };
    let _ = brotli::enc::command::CommandRestoreDistanceCode(&command, &params);
}
use brotli::enc::command::PrefixEncodeCopyDistance;

fn main() {
    let mut code = 0;
    let mut extra_bits = 0;
    PrefixEncodeCopyDistance(100, 0, 100, &mut code, &mut extra_bits);
}
use brotli::enc::brotli_bit_stream::BrotliBuildAndStoreHuffmanTreeFast;
use brotli::enc::writer::StandardAlloc;
fn main() {
    let mut alloc = StandardAlloc::default();
    BrotliBuildAndStoreHuffmanTreeFast(
        &mut alloc,
        &[0],
        0,
        0,
        &mut [0],
        &mut [0],
        &mut 99999,
        &mut [0],
    );
}
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