Apparently MemoryStream does not check boundaries and it is possible to read past end of stream.