Fix a bad bounds check in component trampolines (#4716)

A `GtU` condition needed to actually be `GeU`, as the comment right
above it stated but apparently I forgot to translate the comment to
actual code. This fixes a fuzz bug that arose from oss-fuzz over the
weekend.
This commit is contained in:
Alex Crichton
2022-08-16 09:20:45 -05:00
committed by GitHub
parent 0f944937c0
commit 1e12645ab1
2 changed files with 28 additions and 4 deletions

View File

@@ -1574,7 +1574,7 @@ impl Compiler<'_, '_> {
// If the byte size of memory is greater than the final address of the // If the byte size of memory is greater than the final address of the
// string then the string is invalid. Note that if it's precisely equal // string then the string is invalid. Note that if it's precisely equal
// then that's ok. // then that's ok.
self.instruction(I64GtU); self.instruction(I64GeU);
self.instruction(BrIf(1)); self.instruction(BrIf(1));
self.instruction(End); self.instruction(End);

View File

@@ -127,7 +127,7 @@ impl fmt::Debug for Record {
} }
} }
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct Tuple { pub struct Tuple {
ty: types::Tuple, ty: types::Tuple,
values: Box<[Val]>, values: Box<[Val]>,
@@ -166,6 +166,16 @@ impl Tuple {
} }
} }
impl fmt::Debug for Tuple {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut tuple = f.debug_tuple("");
for val in self.values() {
tuple.field(val);
}
tuple.finish()
}
}
#[derive(PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct Variant { pub struct Variant {
ty: types::Variant, ty: types::Variant,
@@ -227,7 +237,7 @@ impl fmt::Debug for Variant {
} }
} }
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct Enum { pub struct Enum {
ty: types::Enum, ty: types::Enum,
discriminant: u32, discriminant: u32,
@@ -259,7 +269,13 @@ impl Enum {
} }
} }
#[derive(Debug, PartialEq, Eq, Clone)] impl fmt::Debug for Enum {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.discriminant(), f)
}
}
#[derive(PartialEq, Eq, Clone)]
pub struct Union { pub struct Union {
ty: types::Union, ty: types::Union,
discriminant: u32, discriminant: u32,
@@ -303,6 +319,14 @@ impl Union {
} }
} }
impl fmt::Debug for Union {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple(&format!("U{}", self.discriminant()))
.field(self.payload())
.finish()
}
}
#[derive(PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct Option { pub struct Option {
ty: types::Option, ty: types::Option,