You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Create 0.8.0 folder structure + initial edits
* Realize the folder structure is moot since we cannot use two different solc in Truffle
* Get stricter about versions + remove constructor visibility
* change MAX_UINT
* Change README to reflect new versioning system
* change version
* Remove overflow checks in typecast methods
* Remove overflow check in slice()
Copy file name to clipboardExpand all lines: README.md
+42-3Lines changed: 42 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,52 @@
2
2
3
3
# Solidity Bytes Arrays Utils
4
4
5
-
Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
5
+
Bytes tightly packed arrays' utility library for ethereum contracts written in Solidity.
6
6
7
7
The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
8
8
9
-
Given this library has an all-internal collection of methods it doesn't make sense having it reside in the mainnet. Instead it will only be available in EPM as an installable package.
9
+
Given this library has an all-internal collection of methods it doesn't make sense to have it reside in the mainnet. Instead it will only be available on EPM as an installable package.
10
10
11
-
_Version Notes_:
11
+
## Important Fixes Changelog
12
+
13
+
_**2021-01-07**_
14
+
15
+
A bug regarding zero-length slices was disclosed by @MrChico following an audit to the Optimism codebase.
16
+
17
+
The exact bug happened under the following conditions: if memory slots higher then the current free-memory pointer were tainted before calling the `slice` method with a desired length of `0`, the returned bytes array, instead of being a zero-length slice was an array of arbitrary length based on the values that previously populated that memory region.
18
+
19
+
Overall, the usage of zero-length slices should be pretty unusual and, as such, hopefully, this bug does not have far-reaching implications. Nonetheless, *please update the library to the new version if you're using it in production*.
20
+
21
+
**TL;DR: if you're using the `slice` method with a length parameter of '0' in your codebase, please update to version 0.1.2 of the bytes library ASAP!**
22
+
23
+
_**2020-11-01**_
24
+
25
+
There was a **critical bug** in the `slice` method, reported on an audit to a DXDao codebase.
26
+
27
+
Previously, no checks were being made on overflows of the `_start` and `_length` parameters since previous reviews of the codebase deemed this overflow "unexploitable" because of an inordinate expansion of memory (i.e., reading an immensely large memory offset causing huge memory expansion) resulting in an out-of-gas exception.
28
+
29
+
However, as noted in the review mentioned above, this is not the case. The `slice` method in versions `<=0.9.0` actually allows for arbitrary _kind of_ (i.e., it allows memory writes to very specific values) arbitrary memory writes _in the specific case where these parameters are user-supplied inputs and not hardcoded values (which is uncommon).
30
+
31
+
This made me realize that in permissioned blockchains where gas is also not a limiting factor this could become problematic in other methods and so I updated all typecasting-related methods to include new bound checks as well.
32
+
33
+
**TL;DR: if you're using the `slice` method with user-supplied inputs in your codebase please update the bytes library immediately!**
34
+
35
+
## _Version Notes_:
36
+
37
+
* Starting from version `v0.8.0` the versioning will change to follow compatible Solidity's compiler versions.
38
+
This means that now the library will only compile on Solidity versions `>=0.8.0` so, if you need `<0.8.0` support for your project just use `v0.1.2` of the library with:
0 commit comments