Skip to content

Commit

Permalink
g3-openssl: return unexpected eof error when BIO read 0
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Dec 12, 2024
1 parent c9a5c12 commit d082dfe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/g3-openssl/src/ssl/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ impl<S: AsyncRead + Unpin> Read for SslIoWrapper<S> {
self.with_context(|stream, cx| {
let mut buf = ReadBuf::new(buf);
match stream.poll_read(cx, &mut buf) {
Poll::Ready(Ok(_)) => Ok(buf.filled().len()),
Poll::Ready(Ok(_)) => {
let nr = buf.filled().len();
if nr == 0 {
Err(io::Error::new(
io::ErrorKind::UnexpectedEof,
"connection closed when do SSL BIO read",
))
} else {
Ok(nr)
}
}
Poll::Ready(Err(e)) => Err(e),
Poll::Pending => Err(io::Error::from(io::ErrorKind::WouldBlock)),
}
Expand Down

0 comments on commit d082dfe

Please sign in to comment.