Skip to content

Commit

Permalink
1141 mitigation
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Jun 15, 2024
1 parent db0a827 commit c43a769
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ipa-core/src/cli/playbook/ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ where
)
}

let inputs = buffers.map(BodyStream::from);
let inputs = buffers.map(BodyStream::from_byte_vec);
tracing::info!("Starting query for OPRF");

run_query_and_validate::<HV>(inputs, query_size, clients, query_id, query_config).await
Expand Down
13 changes: 13 additions & 0 deletions ipa-core/src/helpers/transport/stream/box_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ impl WrappedBoxBodyStream {
pub fn empty() -> Self {
WrappedBoxBodyStream(Box::pin(futures::stream::empty()))
}

pub fn from_byte_vec(buf: Vec<u8>) -> Self {
const MAX_CHUNK_SIZE: usize = 1 << 16; // 64 KiB
let mut segment = Bytes::from(buf);
let mut segments = Vec::with_capacity(segment.len() / MAX_CHUNK_SIZE);
while segment.len() > MAX_CHUNK_SIZE {
segments.push(Ok(segment.split_to(MAX_CHUNK_SIZE)));
}
segments.push(Ok(segment));

tracing::info!("[in-memory-infra] created body with {} chunks, each does not exceed {} size", segments.len(), MAX_CHUNK_SIZE);
Self::from_bytes_stream(futures::stream::iter(segments))
}
}

impl Stream for WrappedBoxBodyStream {
Expand Down

0 comments on commit c43a769

Please sign in to comment.