From b9a15471ef2dbfe4b14959f32b165d852c3e6378 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Mon, 9 Mar 2020 11:58:19 +0100 Subject: [PATCH] copy FTP data to memory stream to avoid issues when client is closed before reading is complete, closes #1094 --- src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs index 6398835d..cea724a5 100644 --- a/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs +++ b/src/Kp2aBusinessLogic/Io/NetFtpFileStorage.cs @@ -216,9 +216,12 @@ namespace keepass2android.Io try { using (var cl = GetClient(ioc)) - { - return cl.OpenRead(IocToLocalPath(ioc), FtpDataType.Binary, 0); - } + { + var memStream = new MemoryStream(); + cl.OpenRead(IocToLocalPath(ioc), FtpDataType.Binary, 0).CopyTo(memStream); + memStream.Seek(0, SeekOrigin.Begin); + return memStream; + } } catch (FtpCommandException ex) {