From 618636d7aad507ecc732eb29bfdc2418ed9809a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lambert?= Date: Fri, 1 Dec 2023 13:48:06 +0100 Subject: [PATCH] Fix panic when querying a extended report without certs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien Lambert --- src/firmware/guest/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/firmware/guest/mod.rs b/src/firmware/guest/mod.rs index 0372eb36..528b4f9d 100644 --- a/src/firmware/guest/mod.rs +++ b/src/firmware/guest/mod.rs @@ -122,7 +122,7 @@ impl Firmware { message_version: Option, data: Option<[u8; 64]>, vmpl: Option, - ) -> Result<(AttestationReport, Vec), UserApiError> { + ) -> Result<(AttestationReport, Option>), UserApiError> { let report_request = ReportReq::new(data, vmpl)?; let mut report_response = ReportRsp::default(); @@ -181,6 +181,10 @@ impl Firmware { return Err(UserApiError::FirmwareError(Error::InvalidConfig)); } + if ext_report_request.certs_len == 0 { + return Ok((report_response.report, None)); + } + let certificates: Vec; unsafe { @@ -191,7 +195,7 @@ impl Firmware { } // Return both the Attestation Report, as well as the Cert Table. - Ok((report_response.report, certificates)) + Ok((report_response.report, Some(certificates))) } /// Fetches a derived key from the AMD Secure Processor. The `message_version` will default to `1` if `None` is specified.