Skip to content

UTF-16 decoder can panic on invalid input #44

Closed

Description

@vickenty

This program panics (playground):

use encoding_rs::CoderResult;

fn main() {
    let d = &mut encoding_rs::UTF_16BE.new_decoder_without_bom_handling();
    let b = &mut [0; 4];

    assert_eq!(
        d.decode_to_utf8(&[217, 99], b, false),
        (CoderResult::InputEmpty, 2, 0, false)
    );
    
    let _ = d.decode_to_utf8(&[217, 99], b, true);
}
thread 'main' panicked at 'index out of bounds: the len is 4 but the index is 4', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/encoding_rs-0.8.20/src/lib.rs:3884:21

This is a minimized example of a bug found by a fuzzer in another crate. Let me know if you want full details.

Activity

  1. hsivonen commented on Dec 5, 2019

    @hsivonen
    Owner

    Thank you for the report. I've noticed this report, but I been super-busy this week. I will get to this.

  2. hsivonen commented on Dec 18, 2019

    @hsivonen
    Owner

    Thank you. Fixed. I'll look at another report before pushing a new release.

  3. hsivonen commented on Dec 18, 2019

    @hsivonen
    Owner

    The other bug needs more investigation. This fix is now in 0.8.21 on crates.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions