From 899ea60ccdc1365e6a947e869c92dece986532ea Mon Sep 17 00:00:00 2001 From: Jörg Thalheim Date: Sat, 23 Sep 2023 09:55:20 +0200 Subject: handle eof correctly when reading from pinentry Just now rbw-agent will spin at 200% cores if pinentry fails, which can have various reasons. Now it will just terminate correctly when this happens. --- src/pinentry.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pinentry.rs b/src/pinentry.rs index f7d36c7..e2a83ed 100644 --- a/src/pinentry.rs +++ b/src/pinentry.rs @@ -137,6 +137,14 @@ where .read(&mut data[len..]) .await .map_err(|source| Error::PinentryReadOutput { source })?; + if bytes == 0 { + return Err(Error::PinentryReadOutput { + source: std::io::Error::new( + std::io::ErrorKind::UnexpectedEof, + "unexpected EOF", + ), + }); + } len += bytes; } } -- cgit v1.2.3-54-g00ecf