Skip to content

Commit 1692afe

Browse files
committed
fix: don't unwrap when reading possibly left-over bytes from pack-stream (#1352)
1 parent 7669566 commit 1692afe

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

gix/src/remote/connection/fetch/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub enum Error {
4545
RejectShallowRemote,
4646
#[error(transparent)]
4747
NegotiationAlgorithmConfig(#[from] config::key::GenericErrorWithValue),
48+
#[error("Failed to read remaining bytes in stream")]
49+
ReadRemainingBytes(#[source] std::io::Error),
4850
}
4951

5052
impl gix_protocol::transport::IsSpuriousError for Error {

gix/src/remote/connection/fetch/receive_pack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ where
287287
#[cfg(not(feature = "async-network-client"))]
288288
let has_read_to_end = { rd.stopped_at().is_some() };
289289
if !has_read_to_end {
290-
std::io::copy(&mut rd, &mut std::io::sink()).unwrap();
290+
std::io::copy(&mut rd, &mut std::io::sink()).map_err(Error::ReadRemainingBytes)?;
291291
}
292292
#[cfg(feature = "async-network-client")]
293293
{

0 commit comments

Comments
 (0)