From 7a449148ef39f1f87520e6dd6d458338672892cd Mon Sep 17 00:00:00 2001 From: Kun Lai Date: Mon, 24 Aug 2026 20:07:14 +0800 Subject: [PATCH] fix(quote): mask PERFMON bit out of reserved_other in TDAttributes::parse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The & 0x7F mask was incorrectly applied to input[4] (bit 39, a reserved bit that should be checked) instead of input[7] (bit 63 = PERFMON, which should be excluded from reserved_other). This caused PERFMON=1 to be falsely flagged as 'Reserved bits in TD attributes are set'. The fix moves & 0x7F from input[4] to input[7]: - input[7] & 0x7F: excludes PERFMON (bit 63) from reserved_other ✓ - input[4] (no mask): bit 39 is now correctly checked as reserved ✓ Signed-off-by: Kun Lai --- src/quote.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/quote.rs b/src/quote.rs index 32bf681..d86c153 100644 --- a/src/quote.rs +++ b/src/quote.rs @@ -204,10 +204,11 @@ impl TDAttributes { let kl = (input[3] & 0x80) != 0; // Bit 31 // Extract OTHER flags (bytes 4-7) - let reserved_other = ((input[7] as u32) << 24) + // Mask bit 7 of input[7] (= PERFMON, bit 63) out of reserved_other. + let reserved_other = (((input[7] as u32) & 0x7F) << 24) | ((input[6] as u32) << 16) | ((input[5] as u32) << 8) - | ((input[4] as u32) & 0x7F); + | (input[4] as u32); let perfmon = (input[7] & 0x80) != 0; // Bit 63 Ok(TDAttributes {