Skip to content

char boundary byte indexing panic when using Regex::split #417

Closed

Description

@frewsxcv
extern crate regex;

fn main() {
    let a = std::str::from_utf8(b"\\B(?-u)|0").unwrap();
    let b = std::str::from_utf8(b"\n\xcd\x86").unwrap();
    let c = regex::Regex::new(a).unwrap();
    c.split(b).collect::<Vec<_>>(); 
}
thread 'main' panicked at 'byte index 2 is not a char boundary; it is inside '͆' (bytes 1..3) of `
͆`', src/libcore/str/mod.rs:2232:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

line where the panic happens

found via afl.rs using this fuzz target

Activity

  1. changed the title [-]char boundary byte indexing panic when using Regex::spit[/-] [+]char boundary byte indexing panic when using Regex::split[/+] on Nov 24, 2017
  2. BurntSushi commented on Nov 24, 2017

    @BurntSushi
    Member
  3. frewsxcv commented on Nov 24, 2017

    @frewsxcv
    ContributorAuthor

    @BurntSushi yep, just confirmed it happens in master too. here's a backtrace

  4. BurntSushi commented on Apr 28, 2018

    @BurntSushi
    Member

    This was fixed in regex 0.2.7. In particular, negated word boundaries can match invalid UTF-8, which the new regex-syntax crate now detects correctly. Previous it didn't.

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