Skip to content

Commit

Permalink
Merge pull request #125 from datachainlab/audit-202409-s-2-3
Browse files Browse the repository at this point in the history
S-{2,3}: Fix audit suggestions

Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
  • Loading branch information
bluele authored Nov 20, 2024
2 parents 18c1d6d + 010fbf9 commit e5019a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/lcp-client/src/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl LCPClient {
Ok(())
}

// verify_client_message verifies a client message
/// update_client verifies a client message and updates the state of the client
pub fn update_client(
&self,
ctx: &mut dyn HostClientKeeper,
Expand Down
7 changes: 4 additions & 3 deletions modules/remote-attestation/src/ias_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) fn get_quote(
info!("quote size = {}", quote_size);

let mut qe_report = sgx_report_t::default();
let quote = [0u8; 2048];
let quote: Vec<u8> = vec![0; quote_size as usize];
let p_quote = quote.as_ptr();
let ret = unsafe {
sgx_get_quote(
Expand All @@ -105,7 +105,7 @@ pub(crate) fn get_quote(
if ret != sgx_status_t::SGX_SUCCESS {
return Err(Error::sgx_error(ret, "failed to sgx_get_quote".into()));
}
(quote[..quote_size as usize].to_vec(), qe_report)
(quote, qe_report)
};

// Check qe_report to defend against replay attack
Expand Down Expand Up @@ -415,6 +415,7 @@ pub(crate) fn decode_spid(spid_str: &str) -> Result<sgx_spid_t, Error> {
}
};
let mut spid = sgx_spid_t::default();
spid.id.copy_from_slice(&decoded_vec[..16]);
// the length of `decoded_vec` is 16 because each byte is represented by 2 characters
spid.id.copy_from_slice(&decoded_vec);
Ok(spid)
}

0 comments on commit e5019a3

Please sign in to comment.