Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
substrate
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Denis_P
substrate
Commits
58065048
Commit
58065048
authored
6 years ago
by
Gav
Browse files
Options
Downloads
Patches
Plain Diff
Make memcmp safe.
parent
f41d0785
Branches
47
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
executor/src/wasm_executor.rs
+6
-6
6 additions, 6 deletions
executor/src/wasm_executor.rs
with
6 additions
and
6 deletions
executor/src/wasm_executor.rs
+
6
−
6
View file @
58065048
...
...
@@ -16,8 +16,8 @@
//! Rust implementation of Polkadot contracts.
use
libc
::{
memcmp
,
c_void
};
use
std
::
sync
::
Arc
;
use
std
::
cmp
::
Ordering
;
use
std
::
collections
::
HashMap
;
use
parity_wasm
::{
deserialize_buffer
,
ModuleInstanceInterface
,
ProgramInstance
};
use
parity_wasm
::
interpreter
::{
ItemIndex
,
DummyUserError
};
...
...
@@ -97,11 +97,11 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
ext_memcmp
(
s1
:
*
const
u8
,
s2
:
*
const
u8
,
n
:
usize
)
->
i32
=>
{
if
let
(
Ok
(
sl1
),
Ok
(
sl2
))
=
(
this
.memory
.get
(
s1
,
n
as
usize
),
this
.memory
.get
(
s2
,
n
as
usize
))
{
unsafe
{
memcmp
(
sl1
.as_ptr
()
as
*
const
u8
as
*
const
c_void
,
sl2
.as_ptr
()
as
*
const
u8
as
*
const
c_void
,
n
as
usize
)
as
i32
}
match
sl1
.cmp
(
&
sl2
)
{
Ordering
::
Greater
=>
1
,
Ordering
::
Less
=>
-
1
,
Ordering
::
Equal
=>
0
,
}
}
else
{
return
Err
(
DummyUserError
.into
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment