Browse Source

cranelift-isle: Don't panic on too-large rule priorities (#5236)

Found with ISLE's fuzzer.
pull/5241/head
Jamey Sharp 2 years ago
committed by GitHub
parent
commit
d38631a724
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      cranelift/isle/isle/src/parser.rs

7
cranelift/isle/isle/src/parser.rs

@ -390,7 +390,10 @@ impl<'a> Parser<'a> {
fn parse_rule(&mut self) -> Result<Rule> {
let pos = self.pos();
let prio = if self.is_int() {
Some(self.int()?)
Some(
i64::try_from(self.int()?)
.map_err(|err| self.error(pos, format!("Invalid rule priority: {}", err)))?,
)
} else {
None
};
@ -407,7 +410,7 @@ impl<'a> Parser<'a> {
iflets,
expr,
pos,
prio: prio.map(|prio| i64::try_from(prio).unwrap()),
prio,
});
}
}

Loading…
Cancel
Save