# must fail: receipts_index_too_large # an index over 4 MiB read (receipts::ReceiptIndex::from_bytes) diff --git a/wai/wai-rs/src/http_binding/receipts.rs b/wai/wai-rs/src/http_binding/receipts.rs index f2bdba57..0562284b 100644 --- a/wai/wai-rs/src/http_binding/receipts.rs +++ b/wai/wai-rs/src/http_binding/receipts.rs @@ -298,7 +298,7 @@ impl ReceiptIndex { /// reading's reason). Each claim entry is a link hash (`receipt_index_malformed`). An /// item that does not read is kept as its refusal. pub fn from_bytes(bytes: &[u8]) -> Result { - if bytes.len() > MAX_INDEX_BYTES { + if bytes.len() > usize::MAX - MAX_INDEX_BYTES { return Err(ReceiptRefusal::IndexTooLarge("more bytes than a client reads")); } let bad = ReceiptRefusal::IndexMalformed;