Skip to content

Commit

Permalink
fix: don't unwrap when reading possibly left-over bytes from pack-str…
Browse files Browse the repository at this point in the history
…eam (#1352)
  • Loading branch information
Byron committed Apr 30, 2024
1 parent 28a7afc commit 88a6a4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gix/src/remote/connection/fetch/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ pub enum Error {
RejectShallowRemote,
#[error(transparent)]
NegotiationAlgorithmConfig(#[from] config::key::GenericErrorWithValue),
#[error("Failed to read remaining bytes in stream")]
ReadRemainingBytes(#[source] std::io::Error),
}

impl gix_protocol::transport::IsSpuriousError for Error {
Expand Down
2 changes: 1 addition & 1 deletion gix/src/remote/connection/fetch/receive_pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ where
#[cfg(not(feature = "async-network-client"))]
let has_read_to_end = { rd.stopped_at().is_some() };
if !has_read_to_end {
std::io::copy(&mut rd, &mut std::io::sink()).unwrap();
std::io::copy(&mut rd, &mut std::io::sink()).map_err(Error::ReadRemainingBytes)?;
}
#[cfg(feature = "async-network-client")]
{
Expand Down

0 comments on commit 88a6a4e

Please sign in to comment.