Browse Source

Don't panic when a DefBuffer contains less bytes than its size

If a DefBuffer contains less bytes than its size, the remaining bytes should
be initialized to `0`. I overlooked that `copy_from_slice` requires that
its two slices are the same size, and so this panics in these cases. This
was picked up by fuzzing.
Isaac Woods 4 years ago
parent
commit
0c64768a9e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      aml/src/type2.rs

+ 1 - 1
aml/src/type2.rs

@@ -108,7 +108,7 @@ where
                     }
 
                     let mut buffer = vec![0; buffer_size];
-                    buffer.copy_from_slice(bytes);
+                    (&mut buffer[0..bytes.len()]).copy_from_slice(bytes);
                     (Ok(buffer), context)
                 })
             }),