Fix parse_console_log() function

The parse_console_log() function currently doesn't take into account the
input character count when copying from the input registers, which means
that it could copy garbage to the output buffer if the unused bytes in
the input registers weren't zeroed out. Fix this now.

Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: I8ebfa391999fc69b2e6be171fd39866ba20e868d
diff --git a/src/lib.rs b/src/lib.rs
index 7a93b99..57f88b6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,7 +10,7 @@
 use num_enum::{IntoPrimitive, TryFromPrimitive};
 use thiserror::Error;
 use uuid::Uuid;
-use zerocopy::transmute;
+use zerocopy::{transmute, IntoBytes};
 
 pub mod boot_info;
 mod ffa_v1_1;
@@ -2374,17 +2374,13 @@
             if !(1..=CONSOLE_LOG_32_MAX_CHAR_CNT).contains(&char_cnt) {
                 return Err(FfaError::InvalidParameters);
             }
-            for (i, reg) in regs.iter().enumerate() {
-                log_bytes[4 * i..4 * (i + 1)].copy_from_slice(&reg.to_le_bytes());
-            }
+            log_bytes[..char_cnt.into()].copy_from_slice(&regs.as_bytes()[0..char_cnt.into()]);
         }
         ConsoleLogChars::Reg64(regs) => {
             if !(1..=CONSOLE_LOG_64_MAX_CHAR_CNT).contains(&char_cnt) {
                 return Err(FfaError::InvalidParameters);
             }
-            for (i, reg) in regs.iter().enumerate() {
-                log_bytes[8 * i..8 * (i + 1)].copy_from_slice(&reg.to_le_bytes());
-            }
+            log_bytes[..char_cnt.into()].copy_from_slice(&regs.as_bytes()[0..char_cnt.into()]);
         }
     }