Selaa lähdekoodia

[runtime/import/merkle] check if buffer is fully read

ertosns 2 vuotta sitten
vanhempi
sitoutus
a4666d2549
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      src/runtime/import/merkle.rs

+ 4 - 1
src/runtime/import/merkle.rs

@@ -115,7 +115,10 @@ pub(crate) fn merkle_add(ctx: FunctionEnvMut<Env>, ptr: WasmPtr<u8>, len: u32) -
                 }
                 }
             };
             };
 
 
-            // TODO: Ensure we've read the entire buffer above.
+            if buf_reader.position() != (len as u64) {
+                error!(target: "runtime::merkle", "Mismatch between given length, and cursor length");
+                return -2
+            }
 
 
             // Read the current tree
             // Read the current tree
             let ret = match env
             let ret = match env