You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

wasmparser

Package Overview
Dependencies
Maintainers
0
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wasmparser - cargo Package Compare versions

Comparing version
0.241.2
to
0.242.0
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "a1712da0354bea5a38275d7ddf30f707b5757a68"
"sha1": "8ebed07de87638d991e144fa5b79b904b1758987"
},
"path_in_vcs": "crates/wasmparser"
}

@@ -592,3 +592,3 @@ # This file is automatically @generated by Cargo.

name = "wasmparser"
version = "0.241.2"
version = "0.242.0"
dependencies = [

@@ -595,0 +595,0 @@ "anyhow",

@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

name = "wasmparser"
version = "0.241.2"
version = "0.242.0"
authors = ["Yury Delendik <ydelendik@mozilla.com>"]

@@ -19,0 +19,0 @@ build = "build.rs"

@@ -163,6 +163,24 @@ /* Copyright 2024 Mozilla Foundation

fn visit_struct_new(module: &dyn ModuleArity, ty: u32) -> Option<(u32, u32)> {
let (params, _results) = module.sub_type_arity(module.sub_type_at(ty)?)?;
Some((params, 1))
let ty = module.sub_type_at(ty)?;
let descriptor = if let Some(_) = ty.composite_type.descriptor_idx {
1
} else {
0
};
let (params, _results) = module.sub_type_arity(ty)?;
Some((params + descriptor, 1))
}
fn visit_struct_new_default(module: &dyn ModuleArity, ty: u32) -> Option<(u32, u32)> {
let ty = module.sub_type_at(ty)?;
Some((
if let Some(_) = ty.composite_type.descriptor_idx {
1
} else {
0
},
1,
))
}
fn visit_array_new_fixed(_module: &dyn ModuleArity, _ty: u32, size: u32) -> Option<(u32, u32)> {

@@ -293,1 +311,21 @@ Some((size, 1))

}
fn visit_br_on_cast_desc(
module: &dyn ModuleArity,
depth: u32,
_from: RefType,
_to: RefType,
) -> Option<(u32, u32)> {
let (params, _) = visit_br(module, depth)?;
Some((params + 1, params))
}
fn visit_br_on_cast_desc_fail(
module: &dyn ModuleArity,
depth: u32,
_from: RefType,
_to: RefType,
) -> Option<(u32, u32)> {
let (params, _) = visit_br(module, depth)?;
Some((params + 1, params))
}

@@ -303,2 +303,5 @@ macro_rules! define_wasm_features {

pub bulk_memory_opt: BULK_MEMORY_OPT(1 << 35) = true;
// Custom descriptors proposal.
pub custom_descriptors: CUSTOM_DESCRIPTORS(1 << 36) = false;
}

@@ -305,0 +308,0 @@ }

@@ -280,2 +280,11 @@ /* Copyright 2018 Mozilla Foundation

}
HeapType::Exact(_) => {
// Exact types were introduced wit hthe custom descriptors
// proposal.
if self.custom_descriptors() {
Ok(())
} else {
Err("custom descriptors required for exact reference types")
}
}
HeapType::Abstract { shared, ty } => {

@@ -282,0 +291,0 @@ use AbstractHeapType::*;

@@ -841,3 +841,3 @@ //! State relating to validating a WebAssembly module.

HeapType::Abstract { .. } => return Ok(()),
HeapType::Concrete(type_index) => type_index,
HeapType::Concrete(type_index) | HeapType::Exact(type_index) => type_index,
};

@@ -844,0 +844,0 @@ match type_index {

@@ -118,2 +118,3 @@ //! Canonicalization of types.

self.check_subtype(rec_group_id, id, types, offset)?;
self.check_descriptors(rec_group_id, id, types, offset)?;
}

@@ -166,2 +167,119 @@ }

fn check_descriptors(
&mut self,
rec_group: RecGroupId,
id: CoreTypeId,
types: &TypeList,
offset: usize,
) -> Result<()> {
let ty = &types[id].composite_type;
if ty.descriptor_idx.is_some() || ty.describes_idx.is_some() {
if !self.features().custom_descriptors() {
return Err(BinaryReaderError::new(
"custom descriptors proposal must be enabled to use descriptor and describes",
offset,
));
}
match &ty.inner {
CompositeInnerType::Struct(_) => (),
_ => {
return Err(BinaryReaderError::new(
if ty.descriptor_idx.is_some() {
"descriptor clause on non-struct type"
} else {
"describes clause on non-struct type"
},
offset,
));
}
}
}
let map_cannonical = |idx: PackedIndex| -> Result<CoreTypeId> {
self.at_packed_index(types, rec_group, idx, offset)
};
let descriptor_idx = if let Some(i) = ty.descriptor_idx {
Some(map_cannonical(i)?)
} else {
None
};
let describes_idx = if let Some(i) = ty.describes_idx {
Some(map_cannonical(i)?)
} else {
None
};
if let Some(supertype_index) = types[id].supertype_idx {
debug_assert!(supertype_index.is_canonical());
let sup_id = map_cannonical(supertype_index)?;
if let Some(descriptor_idx) = descriptor_idx {
if types[sup_id].composite_type.descriptor_idx.is_some()
&& (types[descriptor_idx].supertype_idx.is_none()
|| (map_cannonical(types[descriptor_idx].supertype_idx.unwrap())?
!= map_cannonical(
types[sup_id].composite_type.descriptor_idx.unwrap(),
)?))
{
bail!(
offset,
"supertype of described type must be described by supertype of descriptor",
);
}
} else if types[sup_id].composite_type.descriptor_idx.is_some() {
bail!(
offset,
"supertype of type without descriptor cannot have descriptor",
);
}
match (
types[id].composite_type.describes_idx,
types[sup_id].composite_type.describes_idx,
) {
(Some(a), Some(b)) => {
let a_id = self.at_packed_index(types, rec_group, a, offset)?;
if types[a_id].supertype_idx.is_none()
|| (map_cannonical(types[a_id].supertype_idx.unwrap())?
!= map_cannonical(b)?)
{
bail!(offset, "supertype of descriptor does not match");
}
}
(None, None) => (),
(None, Some(_)) => {
bail!(
offset,
"supertype of non-descriptor type cannot be a descriptor"
);
}
(Some(_), None) => {
bail!(offset, "supertype of descriptor must be a descriptor");
}
}
}
if let Some(descriptor_idx) = descriptor_idx {
let describes_idx = if let Some(i) = types[descriptor_idx].composite_type.describes_idx
{
Some(map_cannonical(i)?)
} else {
None
};
if describes_idx.is_none() || id != describes_idx.unwrap() {
bail!(offset, "descriptor with no matching describes",);
}
}
if let Some(describes_idx) = describes_idx {
let descriptor_idx = if let Some(i) = types[describes_idx].composite_type.descriptor_idx
{
Some(map_cannonical(i)?)
} else {
None
};
if descriptor_idx.is_none() || id != descriptor_idx.unwrap() {
bail!(offset, "describes with no matching descriptor",);
}
}
Ok(())
}
fn check_composite_type(

@@ -353,2 +471,8 @@ &mut self,

if let Some(idx) = ty.composite_type.describes_idx.as_mut() {
if idx.as_module_index().map_or(false, |i| i >= type_index) {
bail!(self.offset, "forward describes reference");
}
}
ty.remap_indices(&mut |idx| self.canonicalize_type_index(idx))?;

@@ -355,0 +479,0 @@ }

@@ -338,2 +338,4 @@ use super::operators::{Frame, OperatorValidator, OperatorValidatorAllocations};

shared: false,
descriptor_idx: None,
describes_idx: None,
},

@@ -340,0 +342,0 @@ })

@@ -1139,3 +1139,4 @@ //! Types relating to type information provided by validation.

(HT::Concrete(a), HT::Abstract { shared, ty }) => {
(HT::Concrete(a), HT::Abstract { shared, ty })
| (HT::Exact(a), HT::Abstract { shared, ty }) => {
let a_ty = &subtype(a_group, a).composite_type;

@@ -1157,3 +1158,4 @@ if a_ty.shared != shared {

(HT::Abstract { shared, ty }, HT::Concrete(b)) => {
(HT::Abstract { shared, ty }, HT::Concrete(b))
| (HT::Abstract { shared, ty }, HT::Exact(b)) => {
let b_ty = &subtype(b_group, b).composite_type;

@@ -1174,5 +1176,9 @@ if shared != b_ty.shared {

(HT::Concrete(a), HT::Concrete(b)) => {
(HT::Concrete(a), HT::Concrete(b)) | (HT::Exact(a), HT::Concrete(b)) => {
self.id_is_subtype(core_type_id(a_group, a), core_type_id(b_group, b))
}
(HT::Exact(a), HT::Exact(b)) => core_type_id(a_group, a) == core_type_id(b_group, b),
(HT::Concrete(_), HT::Exact(_)) => false,
}

@@ -1212,3 +1218,3 @@ }

HeapType::Abstract { shared, .. } => shared,
HeapType::Concrete(index) => {
HeapType::Concrete(index) | HeapType::Exact(index) => {
self[index.as_core_type_id().unwrap()].composite_type.shared

@@ -1226,3 +1232,3 @@ }

match *heap_type {
HeapType::Concrete(idx) => {
HeapType::Concrete(idx) | HeapType::Exact(idx) => {
let ty = &self[idx.as_core_type_id().unwrap()].composite_type;

@@ -1229,0 +1235,0 @@ let shared = ty.shared;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display