Last active
June 20, 2023 10:49
-
-
Save webmaster128/abbd468ffe8ffc568779aa32e16dbd43 to your computer and use it in GitHub Desktop.
Diff from https://github.com/JumpCrypto/security-research/blob/master/advisories/2023-003-cosmwasm.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/packages/std/src/memory.rs b/packages/std/src/memory.rs | |
index c331a53c..09462d25 100644 | |
--- a/packages/std/src/memory.rs | |
+++ b/packages/std/src/memory.rs | |
@@ -15,9 +15,21 @@ pub struct Region { | |
pub length: u32, | |
} | |
+ | |
+extern "C" { | |
+ fn addr_validate(source_ptr: u32) -> u32; | |
+} | |
+ | |
/// Creates a memory region of capacity `size` and length 0. Returns a pointer to the Region. | |
/// This is the same as the `allocate` export, but designed to be called internally. | |
pub fn alloc(size: usize) -> *mut Region { | |
+ | |
+ let source = build_region("".as_bytes()); | |
+ let source_ptr = &*source as *const Region as u32; | |
+ | |
+ let result = unsafe { addr_validate(source_ptr) }; | |
+ | |
+ | |
let data: Vec<u8> = Vec::with_capacity(size); | |
let data_ptr = data.as_ptr() as usize; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment