751 Commits

Author SHA1 Message Date
Sergey Pepyakin
975078f752
Merge pull request #147 from icefoxen/issue-145
Replaced mysterous bool's in opcodes with u8
2018-01-17 22:37:44 +03:00
Simon Heath
f390d9a8e4 Renamed VarUint8 to Uint8, which makes since since it's not variable-length
Also fixed a couple other small parts I missed.
2018-01-17 13:52:13 -05:00
Simon Heath
5b19c5fb94 Added VarUint8 serialization/deserialization type. 2018-01-17 13:16:31 -05:00
Simon Heath
95c52451a7 Replaced mysterous bool's in opcodes with u8
I suppose, looking at the code, a bool is always represented as u8,
which is what we want anyway, but since these values are not bools but
placeholder integers that must currently always be 0, having them be
bools is kind of strange.

Replaced the reading/writing of them with VarUint7, which is maybe almost
as invalid, but works.

Resolves issue #145.
2018-01-17 12:11:07 -05:00
NikVolf
0e46126ddb fix & 2018-01-17 17:30:35 +03:00
NikVolf
e1ea2a06e5 clang.wasm ci test 2018-01-17 17:28:19 +03:00
NikVolf
a597cdb15d bump version 2018-01-15 11:48:43 +03:00
Nikolay Volf
19494e9e4f
Merge pull request #144 from icefoxen/wrap-typo-fix
Fix typo: Warp -> Wrap
2018-01-15 12:48:02 +04:00
Simon Heath
516de9a725 Fix typo: Warp -> Wrap 2018-01-14 13:30:44 -05:00
NikVolf
e082e3b082 bump version 2018-01-10 19:01:44 +04:00
Nikolay Volf
360c106ccf
Merge pull request #138 from icefoxen/element-debug
Added Debug to lots of the `elements` types.
2018-01-10 19:01:05 +04:00
NikVolf
1b578c196f bump version 2018-01-10 12:07:56 +04:00
Nikolay Volf
657ee416c5
Merge pull request #142 from paritytech/doc-update
Fix missing docs warnings
2018-01-10 12:07:21 +04:00
NikVolf
e2ccf3d3bc fix warnings 2018-01-10 11:41:52 +04:00
Nikolay Volf
e76f33d6c8
Merge pull request #137 from icefoxen/doc-fixes
Minor doc fixes
2018-01-10 11:26:19 +04:00
Nikolay Volf
19382c6d96
Merge pull request #140 from icefoxen/magic-fix2
Made default module magic number endian-independent.
2018-01-10 11:07:10 +04:00
Simon Heath
bddeb51f02 Made default module magic number endian-independent.
And added unit test.  You can change the `LittleEndian` to `BigEndian`
in `Module::default()` and see what it would otherwise do when built
on a big-endian platform.
2018-01-09 19:45:34 -05:00
Simon Heath
588706b7e8 Added Debug to lots of the elements types.
Because when I'm trying to debug my program it's nice to be able
to print out the pieces of it.

Also added Copy and Clone to a few types that could use it, just 'cause.
2018-01-09 18:35:23 -05:00
Simon Heath
5c42a7af1f Trivial fix to README example 2018-01-09 13:38:09 -05:00
Simon Heath
e4c37fd603 Simplified docs for interpreter::native_module() a little 2018-01-09 13:08:19 -05:00
NikVolf
f13a138143 bump version 2018-01-09 19:56:14 +04:00
Nikolay Volf
08ab201787
Merge pull request #136 from paritytech/expose-builder
Expose builder structs for docs
2018-01-09 19:42:22 +04:00
NikVolf
a0c3f27b32 export builders doc effort 2018-01-09 12:53:20 +03:00
NikVolf
6d55afe3ee data builder doc effort 2018-01-09 12:40:04 +03:00
NikVolf
b24ca8ee2d rearrange exports 2018-01-09 12:37:19 +03:00
NikVolf
9e037b88aa more code doc effort 2018-01-09 12:36:21 +03:00
NikVolf
07e3fc47b3 code builder doc effort 2018-01-09 12:29:08 +03:00
NikVolf
b26da22e89 expose builders 2018-01-09 12:23:42 +03:00
Sergey Pepyakin
185dbd3b1b
Merge pull request #133 from emk/impl_error
Implement `Error` for error types
2018-01-03 17:34:04 +03:00
Eric Kidd
a1888a5f1f
Fix typos in error messages 2018-01-02 08:17:37 -05:00
Eric Kidd
7fdf6a8bec Fix debug_assert build problem in release mode
Because `debug_assert_eq!` is implemented using `if
cfg!(debug_assertions)`, we need to avoid referring to `slow_len` unless
it is actually being included in the build.
2018-01-01 15:33:05 -05:00
Eric Kidd
e7d13ed7d1 Don't allow deserializing names which shouldn't exist
This addresses the potential security issue discussed in the last patch
by implementing custom versions of `deserialize` that check for objects
corresponding to each name.
2018-01-01 15:23:06 -05:00
Eric Kidd
e01c0ef043 Implement Error for error types
This makes it easier to handle errors from parity-wasm in an idiomatic
fashion.

Fixes #125.
2018-01-01 09:43:56 -05:00
Eric Kidd
53d7c8ef3a Implement name section parsing
Spec: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section
Issue: https://github.com/paritytech/parity-wasm#129

This is a basic implementation of *.wasm name sections, including
serialization and deserialization. As per the discussion with @NikVolf
on #129, we implement a custom `IndexMap` type.

Before merging this, we should consider the following issues:

- [ ] SECURITY: The custom `IndexMap` structure is exposed to a denial
  of service attack. This can be easily prevented; see below for discussion.
- [ ] We probably want top-level `mod.module_name_section()`,
  `mod.function_name_section()` and `mod.local_name_section()` APIs to
  make it easy to access the relevant sections. Only one of each section
  is allowed, so this would make semantic sense.
- [ ] We need a real-world *.wasm file with a module and local name sections.
- [ ] It looks like name sections will normally be left unparsed. But we
  should probably go ahead and hook them up to the fuzzer manually.
- [ ] We currently require all entries in an `IndexMap` to be in
  ascending order, as required by the standard. We could relax this
  check if we needed to handle non-compliant files.

Security and `IndexMap`:

It's possible to create a local name section containing three entries,
for the indices `u32::MAX-2`, `u32::MAX-1` and `u32::MAX`, each of
which contains an entry for a local variable with index `u32::MAX`. This
will consume an utterly ridiculous amount of RAM.

There are three possible fixes, all of which are relatively easy:

1. Switch from `IndexMap<T>` to `BTreeMap<u32, T>`.
2. Keep the index `IndexMap<T>` API, but reimplement it using a private
   `BTreeMap<u32, T>`. This allows us to replace the implementation
   later without breaking the API.
3. Keep `IndexMap<T>`, but refuse to deserialize maps containing too
   many gaps. This would require a slightly different `Deserialize` API,
   particular to deal with `IndexMap<IndexMap<String>>`.
2017-12-31 09:57:34 -05:00
NikVolf
42321afa39 bump version 2017-12-28 12:02:38 +03:00
Nikolay Volf
e07700012c
Merge pull request #131 from paritytech/serialize-buf
Deserialize buffer takes slice
2017-12-28 12:02:14 +03:00
NikVolf
96c89eb1d6 fix dependency spec 2017-12-27 16:00:52 +03:00
NikVolf
97257a7865 serialize buffer takes slice 2017-12-27 12:28:42 +03:00
NikVolf
138e35da3b bump version 2017-12-27 12:06:17 +03:00
Nikolay Volf
d5b1547707
Merge pull request #130 from paritytech/mut-str
Fix API for import entry
2017-12-27 12:05:33 +03:00
NikVolf
bb21e9d208 fix api for import entry 2017-12-26 19:08:28 +03:00
Nikolay Volf
9895133048
Merge pull request #124 from paritytech/extract-validation
Extract validation
2017-12-05 20:07:20 +01:00
Sergey Pepyakin
f6891e6de9 clean func 2017-12-05 19:57:07 +01:00
Sergey Pepyakin
7c7e3bd051 use self::Opcode::* 2017-12-05 19:45:06 +01:00
Sergey Pepyakin
dea1f3cac0 Oops 2017-12-05 19:44:40 +01:00
Sergey Pepyakin
3b86a8e335 Fix break condition. 2017-12-05 19:34:38 +01:00
Sergey Pepyakin
7ad604b5ad ok_or_else fixes 2017-12-05 19:32:26 +01:00
Sergey Pepyakin
bef4a644fd Fix braces 2017-12-05 18:56:17 +01:00
Sergey Pepyakin
8bd984b10f Fix imports 2017-12-05 18:54:28 +01:00
Sergey Pepyakin
15b93038f9 Fix matches 2017-12-05 18:54:23 +01:00