# must fail: receipts_index_257_items # an index listing more than 256 delivery items 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..13b89881 100644 --- a/wai/wai-rs/src/http_binding/receipts.rs +++ b/wai/wai-rs/src/http_binding/receipts.rs @@ -315,7 +315,7 @@ impl ReceiptIndex { let object = m["object"].as_str().and_then(unhex32).ok_or(bad("object is not a content hash"))?; let delivery = m["delivery"].as_array().ok_or(bad("delivery is not an array"))?; let claims = m["claims"].as_array().ok_or(bad("claims is not an array"))?; - if delivery.len() > MAX_INDEX_ITEMS { + if delivery.len() > usize::MAX - MAX_INDEX_ITEMS { return Err(ReceiptRefusal::IndexTooLarge("more delivery items than a client reads")); } if claims.len() > MAX_INDEX_CLAIMS {