diff options
author | Miguel de Icaza <miguel@gnome.org> | 2011-02-14 17:38:02 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2011-02-14 17:41:31 +0300 |
commit | 6c161687ead1a7bc8f1115e4487dc2c231ac70b7 (patch) | |
tree | 8f24975168d023cd6523a9a5ed602e35f7cc9e98 | |
parent | 7acea3000f77b1de8e25c327121a44568123e0d1 (diff) |
[670974] Use the underlying BaseStream to read bytes instead of trying to peek a character.
Peeking a character as it turns out is a really bad idea as it involves the encoder
to pull characters. If the PeekChar happens to read a byte that is part of a
UTF8 string that needs more characters to process we would end up with the reported
crash.
Atsushi Enomoto tracked this down, and the fix is to use the binaryreader.BaseStream
to directly call into ReadByte and Read without ever probing with PeekChar (). It
is not really possible to use BinaryReader.ReadByte since this one can throw on
end-of-buffer conditions instead of returning -1
-rw-r--r-- | mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs b/mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs index 2a42dfa3641..7f948e3dfc6 100644 --- a/mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs +++ b/mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryReader.cs @@ -72,14 +72,12 @@ namespace System.Xml public int ReadByte () { - if (reader.PeekChar () < 0) - return -1; - return reader.ReadByte (); + return reader.BaseStream.ReadByte (); } public int Read (byte [] data, int offset, int count) { - return reader.Read (data, offset, count); + return reader.BaseStream.Read (data, offset, count); } } |