From 2fd036928cd6a2feda3c4a3e49c3395b9e10c586 Mon Sep 17 00:00:00 2001 From: Marcos Henrich Date: Thu, 25 Feb 2016 18:39:30 +0000 Subject: [PATCH] [corlib] Fixed FileStream Write after Read issue FileStream was writing to the wrong position When a value longer than the FileStream buffer was written after a read. This was fixed by doing a seek before doing the problematic write. Fixes #11699 --- mcs/class/corlib/System.IO/FileStream.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mcs/class/corlib/System.IO/FileStream.cs b/mcs/class/corlib/System.IO/FileStream.cs index 9de058fbb3a..42a3984b11d 100644 --- a/mcs/class/corlib/System.IO/FileStream.cs +++ b/mcs/class/corlib/System.IO/FileStream.cs @@ -639,6 +639,13 @@ namespace System.IO MonoIOError error; FlushBuffer (); + + if (CanSeek && !isExposed) { + MonoIO.Seek (safeHandle, buf_start, SeekOrigin.Begin, out error); + if (error != MonoIOError.ERROR_SUCCESS) + throw MonoIO.GetException (GetSecureFileName (name), error); + } + int wcount = count; while (wcount > 0){ -- 2.25.1